Quickstart

Dive right into code examples to get up and running as quickly as possible (5 - 15 minutes)! This quick guide shows you how to:

  • Install Python and MFlux.ai dependencies
  • Set up a simple machine learning script
  • Push metrics and models to MFlux.ai
  • View the logged metrics and models in the web-based dashboard

1) Log in to MFlux.ai

Log in with GitHub

2) Install Anaconda on your computer

Downloading, installing and managing data science-related python dependencies manually can sometimes be hard and tedious. Anaconda to the rescue! It's a bundle that includes the package manager conda, Python and a number of common python dependencies for data science applications. Download and install it if you don't have it already (you should get the Python 3.* version):

https://www.anaconda.com/download/

When Anaconda is installed, open "Anaconda Prompt" or any other terminal where you have conda available now.

3) Make an isolated Python environment

A virtual environment is a named, isolated, working copy of Python that maintains its own files, directories, and paths so that you can work with specific versions of libraries or Python itself without affecting other Python projects. Virtual environments make it easy to cleanly separate different projects and avoid problems with different dependencies and version requirements across components.

Run conda create --name mflux-quickstart python=3.6.6 in your terminal.

Then, to activate your new environment, run conda activate mflux-quickstart

4) Install MLflow

MLflow is an open source platform to manage the ML lifecycle, including experimentation, reproducibility and deployment. It is neatly integrated with MFlux.ai.

Run pip install mlflow[extras]==1.3.0 "mflux-ai>=0.5.3" in your terminal. This may take a couple of minutes

5) Make a script that trains and evaluates a toy machine learning model

Create a new file train_model.py and paste in the following code:
import mlflow.sklearn
import mflux_ai
from sklearn import datasets
from sklearn.dummy import DummyClassifier
from sklearn.model_selection import train_test_split

iris = datasets.load_iris()

input_data = iris["data"]
target_data = iris["target"]

print("Input data shape: {}".format(input_data.shape))
print("Target data shape: {}".format(target_data.shape))

x_train, x_test, y_train, y_test = train_test_split(
    input_data, target_data, test_size=0.3, random_state=0
)

# Initialize a classifier and fit the model to the data
model = DummyClassifier(strategy="most_frequent")
model.fit(x_train, y_train)

# Evaluate the model on unseen data
validation_accuracy = model.score(x_test, y_test)
print("Validation accuracy: {:.3f}".format(validation_accuracy))

Now try to run that python file: python train_model.py

The output should look somewhat like this:

Input data shape: (150, 4)
Target data shape: (150,)
Mean validation accuracy: 0.244

The validation accuracy is bad at this point, and that's because we have used a DummyClassifier. We'll use something better afterwards.

6) Create a project for this quickstart

Go to the dashboard and create a personal project named "Quickstart project". Then come back here and reload the page. If you need help, please contact support.

7) Log metrics and store machine learning model in MFlux.ai

You need to log in to see this step.

Log in with GitHub

8) Check your tracking UI

You need to log in to see this step.

Log in with GitHub

9) Use a better classifier

Replace model = DummyClassifier(strategy="most_frequent") with
model = DecisionTreeClassifier()

Insert the following line near the top of your script:

from sklearn.tree import DecisionTreeClassifier

Run your script again: python train_model.py

Note that the validation accuracy has improved! And both runs have been logged. You should be able to see them in the tracking UI, like this:

Machine learning model tracking UI

This UI lets you inspect each run and download the models that have been logged, amongst other things

If you want, you can also compare multiple runs by checking them and clicking the "Compare" button. You'll see something like this:

Model comparison UI

10) Applying the best model

You need to log in to see this step.

Log in with GitHub

11) Next steps

Congratulations, you have installed and started using a development environment that will help you create robust, reliable and reproducible machine learning systems. Next, try one of our tutorials.


If you ran into an issue or have questions, we are happy to help. Contact us