1/25/2020 Using scikit-learn on Kaggle and AI Platform Prediction | Cloud

You can deploy scikit-learn models trained in Kaggle to AI Platform Prediction for serving predictions at scale.

This AI Adventures episode explains the basic workow about how to take a model trained anywhere, including Kaggle, and serve online predictions from AI Platform Prediction.

1. Train your scikit-learn model on Kaggle. You can see an example in this introduction to scikit-learn (https://www.youtube.com/watch? v=rvVkVsG49uU&feature=youtu.be&list=PLIivdWyY5sqJxnwJhe3etaK7utrBiPBQ2) . See how to create a notebook kernel on Kaggle (https://www.kaggle.com/docs/kernels#notebooks).

2. Save your model using the sklearn.externals.joblib library (https://joblib.readthedocs.io/en/latest/), making sure to name the le model.joblib. Select the Commit & Run button to execute all of your kernel code cells in order. This saves and runs your model training code.

 Note: To export a joblib model artifact compatible with AI Platform Prediction, you must use the version of joblib that is distributed with scikit-learn, not the standalone version. To import this library in Python, use the statement from sklearn.externals import joblib.

3. Download model.joblib from your kernel outputs (#nd-model-les-kaggle).

4. Upload your model.joblib le to Cloud Storage.

5. Create model and version resources on AI Platform (/ml-engine/docs/scikit/deploying-models) using the Cloud Console, providing information about how you trained your model and where you stored it in Cloud Storage.

6. Send a prediction request.

https://cloud.google.com/ml-engine/docs/scikit/using-kaggle/ 1/2 1/25/2020 Using scikit-learn on Kaggle and AI Platform Prediction | Google Cloud

You can download your model les from the Output tab in your kernel.

At the main link to your kernel, https://www.kaggle.com/[YOUR-USER-NAME]/[YOUR-KERNEL- NAME]/:

1. Select the Output tab at the top of the page.

2. Your model.joblib le appears in a list of Data Sources. To download the le, select the Download All button. Alternatively, hover your mouse over the name of the model, and then select the download icon that appears by the model name.

View a video introduction to Kaggle Kernels (https://www.youtube.com/watch? v=FloMHMOU5Bs&index=13&list=PLIivdWyY5sqJxnwJhe3etaK7utrBiPBQ2) and learn more about the advantages of using Kaggle.

See how to deploy a model on AI Platform (/ml-engine/docs/scikit/deploying-models).

View the documentation on Kaggle Kernels (https://www.kaggle.com/docs/kernels).

https://cloud.google.com/ml-engine/docs/scikit/using-kaggle/ 2/2