第2章 衛星画像で観測される雲パターンと うコンマ状の雲 ......9 第2章 衛星画像で観測される雲パターンと 水蒸気パターン* 2.1 雲パターン
Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン...
Transcript of Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン...
![Page 1: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/1.jpg)
Machine Learning デザイン パターン
Lak LakshmananGoogle CloudHead of Data Analytics and AI Solutions
Twitter: @lak_gcp
![Page 2: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/2.jpg)
Design patterns are formalized best practices to solve common problems when designing a software system.
![Page 3: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/3.jpg)
Feature CrossNeutral ClassCheckpointsKeyed PredictionsTransform
https://github.com/GoogleCloudPlatform/ml-design-patterns
![Page 4: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/4.jpg)
01Feature Cross
![Page 5: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/5.jpg)
Can you draw a line to separate the two classes in this problem?
People who buy
People who don’t buy
Inco
me
leve
l
Time since last purchase
![Page 6: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/6.jpg)
The feature cross provides a way to combine features in a linear model
x2
x1
Idea: define a new featurex3 = x1x2
x2 Can we find a rule like:y = sign(b + w1x1 + w2x2 + w3x3)
x3 = x1x2 is > 0
x3 = x1x2 is > 0
x3 = x1x2 is < 0
x3 = x1x2 is < 0
![Page 7: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/7.jpg)
Using feature crosses, you get to treat each scenario independently
x1 x2
weighted sum
x3 = x1x2
w3
The weight of a cell is
essentially the prediction for
that cell
Hour of day Day of week
weighted sum
x3 = x1x2
w3
Traffic
24 7
24x7
![Page 8: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/8.jpg)
Implementing a feature cross
CONCAT(CAST(day_of_week AS STRING), CAST(hour_of_week AS STRING)) AS day_X_hour
Bucketize Numeric features
before crossing:
1
2
3
4
![Page 9: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/9.jpg)
02Neutral Class
![Page 10: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/10.jpg)
Imagine you are training a model that provides guidance on pain relievers
![Page 11: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/11.jpg)
In historical dataset ...
If patient has risk of stomach problem
Acetaminophen
If patient has risk of liver damage
Ibuprofen
Otherwise Pretty arbitrary
![Page 12: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/12.jpg)
Change the problem from binary classification
A I
A I Neutral Class
![Page 13: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/13.jpg)
Problem framing has to be done when data is collected
![Page 14: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/14.jpg)
Example: does a baby need immediate attention?
BINARY
CLASSIFICATION
Neutral class
![Page 15: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/15.jpg)
Other situations where Neutral Class comes in handy
1
2
3
4
Disagreement among human experts
Customer satisfaction scores: treat 1-4 as bad, 8-10 as good and 5-7 as neutral
Improving embeddings, by training only on confident predictions
Improving decisions (eg. stock market trading) by trading only on confident predictions
![Page 16: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/16.jpg)
03Checkpoints
![Page 17: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/17.jpg)
Checkpoints != Saved Models
checkpoint()
save()...
CheckPoint
deploy()SavedModel
Intermediate (many such checkpoints)
Resumable
![Page 18: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/18.jpg)
checkpoint()
Checkpoints
checkpoint()
checkpoint()
save()...fit() eval() fit() eval() deploy()
![Page 19: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/19.jpg)
1. Resilience during long training runs
checkpoint()
checkpoint()
fit() eval() fit() eval()
loader.resto
re(...)
fit()
![Page 20: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/20.jpg)
2. Generalization (early stopping)
Loss
Error
Better approach is to add regularization
![Page 21: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/21.jpg)
3. Fine-tuning
Loss
Error
![Page 22: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/22.jpg)
Checkpointing in Keras
cp_callback = tf.keras.callbacks.ModelCheckpoint(checkpoint_path)history = model.fit(trainds, validation_data=evalds, epochs=NUM_EVALS, steps_per_epoch=steps_per_epoch, verbose=2, # 0=silent, 1=progress bar, 2=one line per epoch callbacks=[cp_callback])model.save(...)
![Page 23: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/23.jpg)
tf.dataset is an out-of-memory iterable
cp_callback = tf.keras.callbacks.ModelCheckpoint(...)history = model.fit(trainds, validation_data=evalds, epochs=15, batch_size=128, callbacks=[cp_callback])
![Page 24: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/24.jpg)
But epochs are problematic
cp_callback = tf.keras.callbacks.ModelCheckpoint(...)history = model.fit(trainds, validation_data=evalds, epochs=15, batch_size=128, callbacks=[cp_callback])
Integer epochs can be expensive when
dataset is millions of examples
Resilience problems when an epoch takes
hours to process
Datasets grow over time.
![Page 25: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/25.jpg)
If you get 100,000 more examples and you train the model and get a higher error, is it because you need to do an early stop or is the new data corrupt in some way? You can’t tell because the prior training was on 15 million examples and the new one is one is on 16.5 million examples.
Datasets grow over
time??.
![Page 26: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/26.jpg)
Virtual Epochs
checkpointsNUM_TRAINING_EXAMPLES
STOP_PT
trainds = trainds.repeat()
![Page 27: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/27.jpg)
Keeping number of steps fixed is a partial answer
NUM_STEPS = 143000BATCH_SIZE = 50 # 100 NUM_CHECKPOINTS = 15cp_callback = tf.keras.callbacks.ModelCheckpoint(...)history = model.fit(trainds, validation_data=evalds, epochs=NUM_CHECKPOINTS, steps_per_epoch=NUM_STEPS // NUM_CHECKPOINTS, batch_size=BATCH_SIZE, callbacks=[cp_callback]) Fails if you do
hyper-parameter
tuning of batch size
![Page 28: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/28.jpg)
Solution: Keep as constant the number of examples you show the model
NUM_TRAINING_EXAMPLES = 1000 * 1000STOP_POINT = 14.3TOTAL_TRAINING_EXAMPLES = int(STOP_POINT * NUM_TRAINING_EXAMPLES)BATCH_SIZE = 100NUM_CHECKPOINTS = 15steps_per_epoch = (TOTAL_TRAINING_EXAMPLES // (BATCH_SIZE*NUM_CHECKPOINTS))cp_callback = tf.keras.callbacks.ModelCheckpoint(...)history = model.fit(trainds, validation_data=evalds, epochs=NUM_CHECKPOINTS, steps_per_epoch=steps_per_epoch, batch_size=BATCH_SIZE, callbacks=[cp_callback])
![Page 29: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/29.jpg)
04Keyed Predictions
![Page 30: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/30.jpg)
Pass-through keys in Keras
# Serving function that passes through [email protected](input_signature=[{ 'is_male': tf.TensorSpec([None,], dtype=tf.string, name='is_male'), 'mother_age': tf.TensorSpec([None,], dtype=tf.float32, name='mother_age'), 'plurality': tf.TensorSpec([None,], dtype=tf.string, name='plurality'), 'gestation_weeks': tf.TensorSpec([None,], dtype=tf.float32, name='gestation_weeks'), 'key': tf.TensorSpec([None,], dtype=tf.string, name='key')}])def my_serve(inputs): feats = inputs.copy() key = feats.pop('key') output = model(feats) return {'key': key, 'babyweight': output}
tf.saved_model.save(model, EXPORT_PATH, signatures={'serving_default': my_serve})
![Page 31: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/31.jpg)
Keyed predictions
Machine Learning
Model
train
save SavedModel load
Machine Learning
ModelServing Function
save SavedModel
features
output
Key, features
Key, output
![Page 32: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/32.jpg)
Why?
k1
k2
k3
k4
k5
k6
k7
k8
k9
k6
k2
k9
k7
k1
k4
k5
k8
k3
SavedModel
Batch predictions
Async Predictions
![Page 33: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/33.jpg)
Why?
k1
k2
k3
k4
k5
k6
k7
k8
k9
k6
k2
k9
k7
k1
k4
k5
k8
k3
SavedModel
Batch predictions
Async Predictions
But … why should the
client supply the keys?
![Page 34: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/34.jpg)
Why?
k1
k2
k3
k4
k5
k6
k7
k8
k9
k6
k2
k9
k7
k1
k4
k5
k8
k3
SavedModel
Batch predictions
Async Predictions
SLICED Evaluation
![Page 35: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/35.jpg)
05Transform
![Page 36: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/36.jpg)
Imagine a model to predict the length of rentals
Machine Learning
Modelduration
dayofweek
station_name
start_date
station_name
Transform
INPUTS FEATURES OUTPUTS
hourofday
![Page 37: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/37.jpg)
Who does transformation during prediction?
Same
Model serving
Deploy
Prediction
Ideally, call with input variables
Inputs
Trained Model
Pre processing
Featurecreation
Trainmodel
Clients
![Page 38: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/38.jpg)
CREATE OR REPLACE MODEL ch09edu.bicycle_modelOPTIONS(input_label_cols=['duration'], model_type='linear_reg')AS
SELECT duration , start_station_name , CAST(EXTRACT(dayofweek from start_date) AS STRING) as dayofweek , CAST(EXTRACT(hour from start_date) AS STRING) as hourofdayFROM `bigquery-public-data.london_bicycles.cycle_hire`
Ideally, client code does not have to know about all the transformations that were carried out
SELECT * FROM ML.PREDICT(MODEL ch09edu.bicycle_model,( 350 AS duration , 'Kings Cross' AS start_station_name , '3' as dayofweek , '18' as hourofday))
Leading cause of training-serving skew
![Page 39: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/39.jpg)
CREATE OR REPLACE MODEL ch09edu.bicycle_modelOPTIONS(input_label_cols=['duration'], model_type='linear_reg')AS
SELECT duration , start_station_name , CAST(EXTRACT(dayofweek from start_date) AS STRING) as dayofweek , CAST(EXTRACT(hour from start_date) AS STRING) as hourofdayFROM `bigquery-public-data.london_bicycles.cycle_hire`
CREATE OR REPLACE MODEL ch09edu.bicycle_modelOPTIONS(input_label_cols=['duration'], model_type='linear_reg')TRANSFORM( SELECT * EXCEPT(start_date) , CAST(EXTRACT(dayofweek from start_date) AS STRING) as dayofweek , CAST(EXTRACT(hour from start_date) AS STRING) as hourofday)ASSELECT duration, start_station_name, start_dateFROM `bigquery-public-data.london_bicycles.cycle_hire`
TRANSFORM ensures transformations are automatically applied during ML.PREDICT
SELECT * FROM ML.PREDICT(MODEL ch09edu.bicycle_model,( 350 AS duration , 'Kings Cross' AS start_station_name , '3' as dayofweek , '18' as hourofday))
SELECT * FROM ML.PREDICT(MODEL ch09edu.bicycle_model,( 350 AS duration , 'Kings Cross' AS start_station_name , CURRENT_TIMESTAMP() as start_date))
![Page 40: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/40.jpg)
In TensorFlow/Keras, do transformations in Lambda Layers so that they are part of the model graph
for lon_col in ['pickup_longitude', 'dropoff_longitude']: # in range -70 to -78
transformed[lon_col] = tf.keras.layers.Lambda(
lambda x: (x+78)/8.0,
name='scale_{}'.format(lon_col)
)(inputs[lon_col])
Moving an ML model to production is much easier if you keep inputs, features, and transforms separate
![Page 41: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/41.jpg)
Transform pattern: the model graph should include the transformations
Machine Learning
Modelduration
dayofweek
station_name
start_date
station_name
Transform
INPUTS FEATURES OUTPUTS
hourofday
![Page 42: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/42.jpg)
06Summary
![Page 43: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/43.jpg)
Chapter Design pattern Problem solved Solution
Data Representation
Feature CrossModel complexity insufficient to learn feature relationships
Help models learn relationships between inputs faster by explicitly making each combination of input values a separate feature
Problem Representation
Neutral ClassThe class label for some subset of examples is essentially arbitrary.
Introduce an additional label for a classification model, disjoint from the current labels
Patterns that Modify Model Training
CheckpointsLost progress during long running training jobs due to machine failure
Store the full state of the model periodically, so that partially trained models are available and can be used to resume training from an intermediate point, instead of starting from scratch
Resilience Keyed Predictions
How to map the model predictions that are returned to the corresponding model input when submitting large prediction jobs
Allow the model to pass through a client-supported key during prediction that can be used to join model inputs to model predictions
Reproducibility Transform
The inputs to a model must be transformed to create the features the model expects and that process must be consistent between training and serving
Explicitly capture and store the transformations applied to convert the model inputs into features
Summary
![Page 44: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/44.jpg)
https://github.com/GoogleCloudPlatform/ml-design-patterns
![Page 45: Machine Learning デザイン パターン · 2021. 1. 22. · Machine Learning デザイン パターン Lak Lakshmanan Google Cloud Head of Data Analytics and AI Solutions Twitter:](https://reader035.fdocument.pub/reader035/viewer/2022081620/610a4c6032cfb84fad3ebda8/html5/thumbnails/45.jpg)
Thank you