Overview

If you use BigML to train machine learning models, you can import those models directly into Modzy. Using BigML with Modzy together provides a number of benefits:

  • BigML offers easy to use AutoML features for supervised and unsupervised learning
  • Modzy offers model deployment, serving, integration, and monitoring on nearly any device

This guide will show you how to export a model from BigML and convert it into an OMI-compliant container image that can be imported into Modzy.

📘

What you will need to get started

  • An exported BigML model
  • Dockerhub account
  • Connection to running Chassis.ml service (either from a local deployment or via publicly-hosted service)

:electric-plug: Integration Workflow

:cloud: Download your model from BigML

In order to download a model that you've trained in BIgML, visit your model's summary page and then select the Download Actionable Model option on the top right of the screen to export your model.

1068

In the language selection box that appears, select Python. Once the model has finished downloading, open up the python file and the copy and paste the model code into a Jupyter notebook.

856

This Python code will look different based on the type of model you build. For some model types (e.g., deepnet, linear regression, logistic regression, ensemble, time series), you will need to install the BigML python SDK to execute this snippet of code.

pip install bigml

Below are some example BigML code snippets that have been exported to Python:

# tree model

def predict_winner(data={}):
    """ Predictor for Winner from model/62abcdf335f2d00768001d67

        Premier League 2011-2012 season stats and team incomes
        Source
        Statistical data at football-data.co.uk[*]
        Financial data at Premier League accounts, 2011-12[*]
        
        [*]football-data.co.uk: http://www.football-data.co.uk/englandm.php
        [*]Premier League accounts, 2011-12: https://docs.google.com/a/bigml.com/spreadsheet/ccc?key=0AonYZs4MzlZbdEF3MC1waGcwZEd0Y2EzdXFoMXVzcmc#gid=0
    """
    if (data.get('home_tv_and_broadcasting_psm_') is None):
        return u'Home'
    if (data['home_tv_and_broadcasting_psm_'] > 50):
        if (data.get('home_commercial_income_psm_') is None):
            return u'Home'
        if (data['home_commercial_income_psm_'] > 94):
            if (data.get('date_day_of_month') is None):
                return u'Home'
            if (data['date_day_of_month'] > 21):
                if (data.get('home_yellow_cards') is None):
                    return u'Home'
                if (data['home_yellow_cards'] > 1):
                    if (data.get('home_corners') is None):
                        return u'Home'
                    if (data['home_corners'] > 13):
                        return u'Away'
                    if (data['home_corners'] <= 13):
                        if (data['home_yellow_cards'] > 3):
                            return u'Away'
                        if (data['home_yellow_cards'] <= 3):
                            return u'Home'
                if (data['home_yellow_cards'] <= 1):
                    if (data.get('away_shots') is None):
                        return u'Home'
                    if (data['away_shots'] > 7):
                        if (data.get('date_day_of_week') is None):
                            return u'Draw'
                        if (data['date_day_of_week'] > 4):
                            return u'Draw'
                        if (data['date_day_of_week'] <= 4):
                            return u'Home'
                    if (data['away_shots'] <= 7):
                        return u'Home'
            if (data['date_day_of_month'] <= 21):
                return u'Home'
        if (data['home_commercial_income_psm_'] <= 94):
            if (data.get('away_commercial_income_psm_') is None):
                return u'Home'
            if (data['away_commercial_income_psm_'] > 24):
                if (data.get('away_red_cards') is None):
                    return u'Away'
                if (data['away_red_cards'] > 0):
                    if (data.get('date_day_of_month') is None):
                        return u'Home'
                    if (data['date_day_of_month'] > 12):
                        if (data.get('away_shots') is None):
                            return u'Draw'
                        if (data['away_shots'] > 6):
                            return u'Draw'
                        if (data['away_shots'] <= 6):
                            return u'Home'
                    if (data['date_day_of_month'] <= 12):
                        return u'Home'
                if (data['away_red_cards'] <= 0):
                    if (data.get('away_tv_and_broadcasting_psm_') is None):
                        return u'Away'
                    if (data['away_tv_and_broadcasting_psm_'] > 96):
                        if (data.get('away_shots') is None):
                            return u'Away'
                        if (data['away_shots'] > 9):
                            if (data.get('home_fouls_committed') is None):
                                return u'Draw'
                            if (data['home_fouls_committed'] > 7):
                                return u'Draw'
                            if (data['home_fouls_committed'] <= 7):
                                return u'Away'
                        if (data['away_shots'] <= 9):
                            if (data.get('away_fouls_committed') is None):
                                return u'Home'
                            if (data['away_fouls_committed'] > 11):
                                return u'Home'
                            if (data['away_fouls_committed'] <= 11):
                                return u'Away'
                    if (data['away_tv_and_broadcasting_psm_'] <= 96):
                        if (data.get('away_corners') is None):
                            return u'Away'
                        if (data['away_corners'] > 6):
                            if (data.get('home_fouls_committed') is None):
                                return u'Home'
                            if (data['home_fouls_committed'] > 13):
                                return u'Away'
                            if (data['home_fouls_committed'] <= 13):
                                return u'Home'
                        if (data['away_corners'] <= 6):
                            return u'Away'
            if (data['away_commercial_income_psm_'] <= 24):
                if (data.get('home_shots') is None):
                    return u'Home'
                if (data['home_shots'] > 22):
                    if (data.get('home_fouls_committed') is None):
                        return u'Draw'
                    if (data['home_fouls_committed'] > 9):
                        if (data['home_fouls_committed'] > 12):
                            return u'Draw'
                        if (data['home_fouls_committed'] <= 12):
                            return u'Away'
                    if (data['home_fouls_committed'] <= 9):
                        return u'Draw'
                if (data['home_shots'] <= 22):
                    if (data.get('away_shots_on_target') is None):
                        return u'Home'
                    if (data['away_shots_on_target'] > 5):
                        if (data.get('home_corners') is None):
                            return u'Draw'
                        if (data['home_corners'] > 8):
                            return u'Away'
                        if (data['home_corners'] <= 8):
                            if (data.get('away_fouls_committed') is None):
                                return u'Draw'
                            if (data['away_fouls_committed'] > 5):
                                if (data.get('home_fouls_committed') is None):
                                    return u'Draw'
                                if (data['home_fouls_committed'] > 10):
                                    if (data['home_corners'] > 6):
                                        return u'Home'
                                    if (data['home_corners'] <= 6):
                                        if (data.get('date_day_of_month') is None):
                                            return u'Draw'
                                        if (data['date_day_of_month'] > 11):
                                            return u'Draw'
                                        if (data['date_day_of_month'] <= 11):
                                            return u'Home'
                                if (data['home_fouls_committed'] <= 10):
                                    if (data.get('date_day_of_week') is None):
                                        return u'Draw'
                                    if (data['date_day_of_week'] > 6):
                                        return u'Home'
                                    if (data['date_day_of_week'] <= 6):
                                        return u'Draw'
                            if (data['away_fouls_committed'] <= 5):
                                return u'Away'
                    if (data['away_shots_on_target'] <= 5):
                        if (data.get('home_corners') is None):
                            return u'Home'
                        if (data['home_corners'] > 7):
                            if (data['home_tv_and_broadcasting_psm_'] > 74):
                                return u'Home'
                            if (data['home_tv_and_broadcasting_psm_'] <= 74):
                                if (data.get('away_yellow_cards') is None):
                                    return u'Draw'
                                if (data['away_yellow_cards'] > 1):
                                    if (data['home_corners'] > 8):
                                        return u'Home'
                                    if (data['home_corners'] <= 8):
                                        return u'Draw'
                                if (data['away_yellow_cards'] <= 1):
                                    return u'Draw'
                        if (data['home_corners'] <= 7):
                            return u'Home'
    if (data['home_tv_and_broadcasting_psm_'] <= 50):
        if (data.get('away_turnover_psm_') is None):
            return u'Away'
        if (data['away_turnover_psm_'] > 79):
            if (data.get('away_tv_and_broadcasting_psm_') is None):
                return u'Away'
            if (data['away_tv_and_broadcasting_psm_'] > 54):
                if (data.get('home_yellow_cards') is None):
                    return u'Away'
                if (data['home_yellow_cards'] > 2):
                    if (data.get('home_shots_on_target') is None):
                        return u'Away'
                    if (data['home_shots_on_target'] > 9):
                        return u'Home'
                    if (data['home_shots_on_target'] <= 9):
                        return u'Away'
                if (data['home_yellow_cards'] <= 2):
                    if (data.get('away_fouls_committed') is None):
                        return u'Away'
                    if (data['away_fouls_committed'] > 12):
                        if (data.get('away_gate_and_matchday_income_psm_') is None):
                            return u'Away'
                        if (data['away_gate_and_matchday_income_psm_'] > 33):
                            if (data.get('home_fouls_committed') is None):
                                return u'Home'
                            if (data['home_fouls_committed'] > 6):
                                return u'Home'
                            if (data['home_fouls_committed'] <= 6):
                                return u'Away'
                        if (data['away_gate_and_matchday_income_psm_'] <= 33):
                            return u'Away'
                    if (data['away_fouls_committed'] <= 12):
                        if (data.get('away_shots') is None):
                            return u'Away'
                        if (data['away_shots'] > 23):
                            return u'Home'
                        if (data['away_shots'] <= 23):
                            if (data['away_fouls_committed'] > 11):
                                if (data['away_shots'] > 13):
                                    return u'Draw'
                                if (data['away_shots'] <= 13):
                                    return u'Home'
                            if (data['away_fouls_committed'] <= 11):
                                if (data.get('away_red_cards') is None):
                                    return u'Away'
                                if (data['away_red_cards'] > 0):
                                    if (data.get('home_fouls_committed') is None):
                                        return u'Home'
                                    if (data['home_fouls_committed'] > 9):
                                        return u'Draw'
                                    if (data['home_fouls_committed'] <= 9):
                                        return u'Home'
                                if (data['away_red_cards'] <= 0):
                                    if (data.get('date_day_of_week') is None):
                                        return u'Away'
                                    if (data['date_day_of_week'] > 6):
                                        return u'Away'
                                    if (data['date_day_of_week'] <= 6):
                                        if (data.get('home_fouls_committed') is None):
                                            return u'Away'
                                        if (data['home_fouls_committed'] > 7):
                                            if (data.get('away_corners') is None):
                                                return u'Away'
                                            if (data['away_corners'] > 9):
                                                return u'Away'
                                            if (data['away_corners'] <= 9):
                                                if (data.get('home_shots') is None):
                                                    return u'Draw'
                                                if (data['home_shots'] > 15):
                                                    return u'Away'
                                                if (data['home_shots'] <= 15):
                                                    if (data['away_shots'] > 12):
                                                        return u'Draw'
                                                    if (data['away_shots'] <= 12):
                                                        if (data['home_fouls_committed'] > 8):
                                                            return u'Away'
                                                        if (data['home_fouls_committed'] <= 8):
                                                            return u'Draw'
                                        if (data['home_fouls_committed'] <= 7):
                                            if (data.get('home_corners') is None):
                                                return u'Away'
                                            if (data['home_corners'] > 2):
                                                return u'Away'
                                            if (data['home_corners'] <= 2):
                                                return u'Draw'
            if (data['away_tv_and_broadcasting_psm_'] <= 54):
                if (data.get('home_fouls_committed') is None):
                    return u'Draw'
                if (data['home_fouls_committed'] > 8):
                    if (data.get('away_shots') is None):
                        return u'Away'
                    if (data['away_shots'] > 8):
                        if (data.get('away_yellow_cards') is None):
                            return u'Away'
                        if (data['away_yellow_cards'] > 0):
                            return u'Away'
                        if (data['away_yellow_cards'] <= 0):
                            if (data.get('home_corners') is None):
                                return u'Draw'
                            if (data['home_corners'] > 9):
                                return u'Away'
                            if (data['home_corners'] <= 9):
                                return u'Draw'
                    if (data['away_shots'] <= 8):
                        return u'Draw'
                if (data['home_fouls_committed'] <= 8):
                    if (data.get('home_shots_on_target') is None):
                        return u'Draw'
                    if (data['home_shots_on_target'] > 11):
                        return u'Home'
                    if (data['home_shots_on_target'] <= 11):
                        return u'Draw'
        if (data['away_turnover_psm_'] <= 79):
            if (data.get('home_turnover_psm_') is None):
                return u'Home'
            if (data['home_turnover_psm_'] > 73):
                if (data.get('date_day_of_month') is None):
                    return u'Home'
                if (data['date_day_of_month'] > 26):
                    return u'Draw'
                if (data['date_day_of_month'] <= 26):
                    if (data['date_day_of_month'] > 21):
                        if (data['home_tv_and_broadcasting_psm_'] > 48):
                            return u'Home'
                        if (data['home_tv_and_broadcasting_psm_'] <= 48):
                            if (data.get('away_red_cards') is None):
                                return u'Away'
                            if (data['away_red_cards'] > 0):
                                return u'Home'
                            if (data['away_red_cards'] <= 0):
                                return u'Away'
                    if (data['date_day_of_month'] <= 21):
                        if (data.get('away_corners') is None):
                            return u'Home'
                        if (data['away_corners'] > 3):
                            if (data.get('away_fouls_committed') is None):
                                return u'Home'
                            if (data['away_fouls_committed'] > 6):
                                if (data.get('away_shots') is None):
                                    return u'Draw'
                                if (data['away_shots'] > 12):
                                    return u'Draw'
                                if (data['away_shots'] <= 12):
                                    if (data.get('home_yellow_cards') is None):
                                        return u'Home'
                                    if (data['home_yellow_cards'] > 0):
                                        if (data['away_shots'] > 8):
                                            return u'Home'
                                        if (data['away_shots'] <= 8):
                                            if (data.get('home_corners') is None):
                                                return u'Draw'
                                            if (data['home_corners'] > 8):
                                                return u'Home'
                                            if (data['home_corners'] <= 8):
                                                return u'Draw'
                                    if (data['home_yellow_cards'] <= 0):
                                        return u'Draw'
                            if (data['away_fouls_committed'] <= 6):
                                return u'Home'
                        if (data['away_corners'] <= 3):
                            if (data.get('away_shots') is None):
                                return u'Away'
                            if (data['away_shots'] > 5):
                                return u'Away'
                            if (data['away_shots'] <= 5):
                                if (data.get('home_fouls_committed') is None):
                                    return u'Home'
                                if (data['home_fouls_committed'] > 7):
                                    return u'Home'
                                if (data['home_fouls_committed'] <= 7):
                                    return u'Draw'
            if (data['home_turnover_psm_'] <= 73):
                if (data.get('date_month') is None):
                    return u'Away'
                if (data['date_month'] > 2):
                    if (data.get('away_shots_on_target') is None):
                        return u'Home'
                    if (data['away_shots_on_target'] > 12):
                        return u'Draw'
                    if (data['away_shots_on_target'] <= 12):
                        if (data['home_tv_and_broadcasting_psm_'] > 42):
                            if (data.get('home_shots_on_target') is None):
                                return u'Home'
                            if (data['home_shots_on_target'] > 6):
                                if (data['home_shots_on_target'] > 9):
                                    if (data.get('away_commercial_income_psm_') is None):
                                        return u'Home'
                                    if (data['away_commercial_income_psm_'] > 7):
                                        return u'Draw'
                                    if (data['away_commercial_income_psm_'] <= 7):
                                        return u'Home'
                                if (data['home_shots_on_target'] <= 9):
                                    if (data.get('home_corners') is None):
                                        return u'Away'
                                    if (data['home_corners'] > 6):
                                        if (data.get('home_fouls_committed') is None):
                                            return u'Away'
                                        if (data['home_fouls_committed'] > 14):
                                            return u'Away'
                                        if (data['home_fouls_committed'] <= 14):
                                            if (data['home_fouls_committed'] > 9):
                                                return u'Home'
                                            if (data['home_fouls_committed'] <= 9):
                                                return u'Away'
                                    if (data['home_corners'] <= 6):
                                        if (data.get('away_fouls_committed') is None):
                                            return u'Away'
                                        if (data['away_fouls_committed'] > 8):
                                            return u'Away'
                                        if (data['away_fouls_committed'] <= 8):
                                            if (data.get('home_fouls_committed') is None):
                                                return u'Draw'
                                            if (data['home_fouls_committed'] > 9):
                                                return u'Draw'
                                            if (data['home_fouls_committed'] <= 9):
                                                return u'Away'
                            if (data['home_shots_on_target'] <= 6):
                                if (data.get('away_tv_and_broadcasting_psm_') is None):
                                    return u'Home'
                                if (data['away_tv_and_broadcasting_psm_'] > 44):
                                    if (data.get('away_shots') is None):
                                        return u'Draw'
                                    if (data['away_shots'] > 6):
                                        return u'Draw'
                                    if (data['away_shots'] <= 6):
                                        return u'Home'
                                if (data['away_tv_and_broadcasting_psm_'] <= 44):
                                    return u'Home'
                        if (data['home_tv_and_broadcasting_psm_'] <= 42):
                            if (data.get('away_gate_and_matchday_income_psm_') is None):
                                return u'Away'
                            if (data['away_gate_and_matchday_income_psm_'] > 9):
                                return u'Home'
                            if (data['away_gate_and_matchday_income_psm_'] <= 9):
                                if (data.get('away_fouls_committed') is None):
                                    return u'Away'
                                if (data['away_fouls_committed'] > 12):
                                    return u'Home'
                                if (data['away_fouls_committed'] <= 12):
                                    return u'Away'
                if (data['date_month'] <= 2):
                    if (data.get('date_day_of_month') is None):
                        return u'Away'
                    if (data['date_day_of_month'] > 23):
                        return u'Home'
                    if (data['date_day_of_month'] <= 23):
                        if (data.get('away_shots') is None):
                            return u'Away'
                        if (data['away_shots'] > 16):
                            if (data.get('home_fouls_committed') is None):
                                return u'Home'
                            if (data['home_fouls_committed'] > 8):
                                return u'Home'
                            if (data['home_fouls_committed'] <= 8):
                                return u'Away'
                        if (data['away_shots'] <= 16):
                            return u'Away'
# Requires BigML Python bindings
#
# Install via: pip install bigml
#
# or clone it:
#   git clone https://github.com/bigmlcom/python.git

from bigml.ensemble import Ensemble

# Downloads and generates a local version of the ensemble, if it
# hasn't been downloaded previously.
from bigml.api import BigML



ensemble = Ensemble('ensemble/62abd48caba2df28f7002648',
                    api=BigML("bmunday1",
                              "640ef9fba083307aef1b9345934dbf59500b7199",
                              domain="bigml.io"))

# To make predictions fill the desired input_data in next line.
input_data = {}

ensemble.predict(input_data, full=True)

#
# input_data: dict for the input values
# (e.g. {"petal length": 1, "sepal length": 3})
# full: if set to True, the output will be a dictionary that includes all the
# available information in the predicted node. The attributes vary depending
# on the ensemble type. Please check:
# https://bigml.readthedocs.io/en/latest/#local-ensemble-s-predictions
# Requires BigML Python bindings
#
# Install via: pip install bigml
#
# or clone it:
#   git clone https://github.com/bigmlcom/python.git

from bigml.linear import LinearRegression
from bigml.api import BigML

# Downloads and generates a local version of the linear regression,
# if it hasn't been downloaded previously.

linearregression = LinearRegression('linearregression/62abd4c0aba2df28fd002392',
                  api=BigML("bmunday1",
                            "640ef9fba083307aef1b9345934dbf59500b7199",
                            domain="bigml.io"))

# To make predictions fill the desired input_data
# in next line. All fields are compulsory if they don't have
# missing values.
input_data = {
    "Winner": "Home",
    "Away Turnover (£m)": 1,
    "Home Commercial income (£m)": 1,
    "Away TV and Broadcasting (£m)": 1,
    "Away Gate and Matchday income (£m)": 1,
    "Home TV and Broadcasting (£m)": 1,
    "Home Turnover (£m)": 1,
    "Home Gate and Matchday income (£m)": 1,
    "Home red cards": 1,
    "Away red cards": 1,
    "Away yellow cards": 1,
    "Date.day-of-week": 1,
    "Date.day-of-month": 1,
    "Date.month": 1,
    "Date.year": 1,
    "Away fouls committed": 1,
    "Home corners": 1,
    "Away shots on target": 1,
    "Home fouls committed": 1,
    "Away shots": 1,
    "Home shots on target": 1,
    "Date": 1,
    "Home shots": 1,
    "Away corners": 1,
    "Home yellow cards": 1
}
linearregression.predict(input_data)
# Requires BigML Python bindings
#
# Install via: pip install bigml
#
# or clone it:
#   git clone https://github.com/bigmlcom/python.git

from bigml.logistic import LogisticRegression
from bigml.api import BigML

# Downloads and generates a local version of the logistic regression,
# if it hasn't been downloaded previously.

logisticregression = LogisticRegression('logisticregression/62abd2428be2aa5e72001a19',
                  api=BigML("bmunday1",
                            "640ef9fba083307aef1b9345934dbf59500b7199",
                            domain="bigml.io"))

# To predict probabilities fill the desired input_data
# in next line. Numeric fields are compulsory if the model was not
# trained with missing numerics.
input_data = {
    "Away Commercial income (£m)": 1,
    "Away Turnover (£m)": 1,
    "Home Commercial income (£m)": 1,
    "Away TV and Broadcasting (£m)": 1,
    "Away Gate and Matchday income (£m)": 1,
    "Home TV and Broadcasting (£m)": 1,
    "Home Turnover (£m)": 1,
    "Home Gate and Matchday income (£m)": 1,
    "Home red cards": 1,
    "Away red cards": 1,
    "Away yellow cards": 1,
    "Date.day-of-week": 1,
    "Date.day-of-month": 1,
    "Date.month": 1,
    "Date.year": 1,
    "Away fouls committed": 1,
    "Home corners": 1,
    "Away shots on target": 1,
    "Home fouls committed": 1,
    "Away shots": 1,
    "Home shots on target": 1,
    "Date": 1,
    "Home shots": 1,
    "Away corners": 1,
    "Home yellow cards": 1
}
logisticregression.predict(input_data, full=True)

#
# input_data: dict for the input values
# (e.g. {"petal length": 1, "sepal length": 3})
# full: if set to True, the output will be a dictionary that includes the
# distribution of each class in the objective field, the predicted class and
# its probability. Please check:
# https://bigml.readthedocs.io/en/latest/#local-logistic-regression-predictions
# deepnet

# Requires BigML Python bindings
#
# Install via: pip install bigml
#
# or clone it:
#   git clone https://github.com/bigmlcom/python.git

from bigml.deepnet import Deepnet
from bigml.api import BigML

# Downloads and generates a local version of the DEEPNET,
# if it hasn't been downloaded previously.

deepnet = Deepnet('deepnet/62abcfb08be2aa5e75001c1f',
                  api=BigML("bmunday1",
                            "640ef9fba083307aef1b9345934dbf59500b7199",
                            domain="bigml.io"))

# To make predictions fill the desired input_data in next line.
input_data = {
    "Away Commercial income (£m)": 1,
    "Away Turnover (£m)": 1,
    "Home Commercial income (£m)": 1,
    "Away TV and Broadcasting (£m)": 1,
    "Away Gate and Matchday income (£m)": 1,
    "Home TV and Broadcasting (£m)": 1,
    "Home Turnover (£m)": 1,
    "Home Gate and Matchday income (£m)": 1,
    "Home red cards": 1,
    "Away red cards": 1,
    "Away yellow cards": 1,
    "Date.day-of-week": 1,
    "Date.day-of-month": 1,
    "Date.month": 1,
    "Date.year": 1,
    "Away fouls committed": 1,
    "Home corners": 1,
    "Away shots on target": 1,
    "Home fouls committed": 1,
    "Away shots": 1,
    "Home shots on target": 1,
    "Date": 1,
    "Home shots": 1,
    "Away corners": 1,
    "Home yellow cards": 1
}
deepnet.predict(input_data, full=True)

#
# input_data: dict for the input values
# (e.g. {"petal length": 1, "sepal length": 3})
# full: if set to True, the output will be a dictionary that includes all the
# available information about the prediction. The attributes vary depending
# on the ensemble type. Please check:
# https://bigml.readthedocs.io/en/latest/#local-deepnet-predictions
# Requires BigML Python bindings
#
# Install via: pip install bigml
#
# or clone it:
#   git clone https://github.com/bigmlcom/python.git

from bigml.timeseries import TimeSeries
from bigml.api import BigML

# Downloads and generates a local version of the TIME SERIES,
# if it hasn't been downloaded previously.

timeseries = TimeSeries('timeseries/62abd4268be2aa5e6e001962',
                  api=BigML("bmunday1",
                            "640ef9fba083307aef1b9345934dbf59500b7199",
                            domain="bigml.io"))

# To forecast the time series fill the desired input_data in the line below.
# Only the ID of the fields to predict with are required,
# you can also specify submodels to calculate.
input_data = {
    "000014": {"horizon": 50}
}
timeseries.forecast(input_data)

# The result is a list of probabilities per forecast which values are between
# 0 and 1.

The final step before you can start converting and importing your BigML to Modzy is to download a sample piece of data for testing. You'll also need to make sure it's formatted to meet your model's input requirements.

You can use the BigML API to download your dataset directly, or save some sample data based on the Python code snippet returned for your model.

input_data = {
    "Winner": "Home",
    "Away Turnover (£m)": 1,
    "Home Commercial income (£m)": 1,
    "Away TV and Broadcasting (£m)": 1,
    "Away Gate and Matchday income (£m)": 1,
    "Home TV and Broadcasting (£m)": 1,
    "Home Turnover (£m)": 1,
    "Home Gate and Matchday income (£m)": 1,
    "Home red cards": 1,
    "Away red cards": 1,
    "Away yellow cards": 1,
    "Date.day-of-week": 1,
    "Date.day-of-month": 1,
    "Date.month": 1,
    "Date.year": 1,
    "Away fouls committed": 1,
    "Home corners": 1,
    "Away shots on target": 1,
    "Home fouls committed": 1,
    "Away shots": 1,
    "Home shots on target": 1,
    "Date": 1,
    "Home shots": 1,
    "Away corners": 1,
    "Home yellow cards": 1
}

import json
with open("sample_premier_league.json", "w") as f:
    json.dump(input_data, f)

:curly-loop: Edit your process function

Next, you'll convert this python function into a container image that can be deployed to Modzy. To start, you'll need to transform the prediction function from Python model code you downloaded into the process function you will need for Chassis. The code below assumes we are using the "Tree Model" exported model.

def process(input_bytes):
    input_data = json.loads(input_bytes)
    prediction = predict_winner(input_data)
    output = {
        "predictedWinner": prediction
    }
    return output

:mailbox-with-mail: Create and save a model container image with chassis.ml

First, connect to a running instance of the Chassis service - either by deploying on your machine or by connecting to the publicly hosted version of the service. Then you can use the process function you defined to create a ChassisModel object and publish your model. Finally, you'll need to provide credentials to your dockerhub account so that your container image can be saved.

chassis_client = chassisml.ChassisClient("http://localhost:5000")
chassis_model = chassis_client.create_model(process_fn=process)

dockerhub_user = <my.username>
dockerhub_pass = <my.password>

response = chassis_model.publish(
   model_name="Premier League Season Winner Prediction",
   model_version="0.0.1",
   registry_user=dockerhub_user,
   registry_pass=dockerhub_pass
)

job_id = response.get('job_id')
final_status = chassis_client.block_until_complete(job_id)

Once you've updated this function, you can run this cell in your Jupyter Notebook and Chassis will start converting your model into a container image. After a few minutes, it will automatically push your BigML model to your Dockerhub account.

1395

:arrow-right: Import container image into Modzy

Lastly, you can deploy your BigML model container into Modzy in just a few simple steps and be ready to run, monitor, and integrate your model at massive scale!


What’s Next