iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 10
0

Let's start another course which is also related to machine learning.

This time we will focus more on Machine Learning Infrastructure.

Don't worry if it sounds not so friendly to you.


Introduction

If you've built machine learning models with scikit-learn, and you want to serve your models in real time for an application, managing the resulting infrastructure may sound like a nightmare. Fortunately, there's an alternative - serving your trained scikit-learn models on AI Platform.

You can now upload a model you've already trained onto Cloud Storage and use AI Platform Prediction to support scalable prediction requests against your trained model.


What we will build

https://ithelp.ithome.com.tw/upload/images/20200923/20130054ese2t0H0DT.png

Let's learn about the different tools you'll be using to get online prediction up and running on AI Platform:

Google Cloud lets you build and host applications and websites, store data, and analyze data on Google's scalable infrastructure.

AI Platform Prediction is a managed service that enables you to easily build machine learning models that work on any type of data, of any size.

Cloud Storage is a unified object storage for developers and enterprises, from live data serving to data analytics/ML to data archiving.

Cloud SDK is a command line tool which allows you to interact with Google Cloud products.


Train and save your model

https://ithelp.ithome.com.tw/upload/images/20200923/20130054MNX6qNzIZk.png

Load the data into a pandas DataFrame to prepare it for use with XGBoost. Train a simple model in XGBoost. Save the model to a file that can be uploaded to AI Platform.


Upload the saved model

https://ithelp.ithome.com.tw/upload/images/20200923/20130054iaulEAz2w6.png

To use your model with AI Platform, you'll need to upload it to Cloud Storage.


Create a model resource

https://ithelp.ithome.com.tw/upload/images/20200923/20130054JIebr4QVud.png

AI Platform organizes your trained models using model and version resources. An AI Platform model is a container for the versions of your machine learning model. More information on model resources and model versions can be found in the scikit-learn documentation.


Create a model version

https://ithelp.ithome.com.tw/upload/images/20200923/201300541CqQnQYUIk.png

Now it's time to get a version of your model uploaded to your container. This will allow you to make online predictions. The model version requires a few components, specified here.

  • name - The name specified for the version when it was created. This will be the VERSION_NAME variable you declared at the beginning.
  • deploymentUri - The Cloud Storage location of the trained model used to create the version. This is the bucket where you uploaded the model with your MODEL_PATH.
  • runtimeVersion - The AI Platform runtime version to use for this deployment. This is set to 1.14.
  • framework - This specifies whether you're using SCIKIT_LEARN or XGBOOST. This is set to SCIKIT_LEARN.
  • pythonVersion - This specifies whether you're using Python 2.7 or Python 3.5. The default value is set to "2.7", if you are using Python 3.5, set the value to "3.5"

Make an online prediction

https://ithelp.ithome.com.tw/upload/images/20200923/20130054g8iWf6b3CO.png

It's time to make an online prediction in Python with your newly deployed model.


This time we gave a brief introduction for each step. /images/emoticon/emoticon39.gif

Hope you enjoy today's sharing~


上一篇
Let's summarize ...
下一篇
Distributed Machine Learning with Google Cloud ML - 1
系列文
Machine Learning Study Jam 202012
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言