Deploying Scikit-Learn Models using Google ML Engine

Shabeel Kandi
4 min readMar 22, 2019
ML Workflow

In this tutorial, we will go through the above ML Workflow end-to-end, resulting in a working model deployed on the cloud.

1. Code your Model

For this tutorial, we will build a model to classify small business stores as either credit-worthy [0] or credit-risky [1]. Thus, a binary classification problem.

We are not going to focus too much on the model itself, all we have to know is that the each store have the following features: ‘Avg ClosingBalance in Past 30 days’, ‘Avg OutStandingBalance in Past 30 days’,
‘Total Credit NIV in Past 30 days’ and ‘CreditLimit'. And using these features, we train and build a model to classify them.

Importing libraries

# [START setup]
import datetime
import os
import subprocess
import sys
from sklearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.externals import joblib
from sklearn.ensemble import RandomForestClassifier
#from xgboost import XGBClassifier
import pandas as pd
import numpy as np

Configuring your Google Cloud Set-up

# Fill in your Cloud…

--

--