Quickstart

Start tracking ML experiments by logging relevant metadata about your models and share with your team. At the end of this tutorial you will know how to add tracking to any of your ML code and see all the tracked data in your own dashboard

Installation

Install the Newron Python client:

pip install newron

alternatively, you can install the client from source:

pip install git+https://github.com/NewronAI/NewronSDK.git

Setup Newron Account

Creating a new Newron account is easy and free. Visit newron and create an account using either your email, google or GitHub credentials. Alternatively, user can also sign up when calling newron.init() while creating a new project or experiment

Ignore this step if you are already signed up.

Click here to SignUp | Login

Create a New Project

To start a new Project or to add new runs in existing project, simply copy and paste the following code into the top of your file and it will start tracking relevant parameters and metrics right out of the box:

import newron
newron.init(project_name="My Project", experiment_name="My Experiment")

Add Tracking

For this quick start, we will be using a iris flower dataset available in sklearn. To follow along, copy the below code in your ide or notebook to load the data. This code loads the iris dataset, do the train-test split and then train a SVM model for classification. BY default, newron sdk will log some basic parameters as shown here using the newron.%framework%.autolog()

#import all the required ML packages
import pandas as pd
import numpy as np
import sklearn
from sklearn import datasets, model_selection, svm, metrics

#import newron sdk to your code
import newron

#newron.sklearn.autolog()

# Load and Prep Data
iris = sklearn.datasets.load_iris()
X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(iris.data,  iris.target, test_size=0.2)

# Model Training
clf = sklearn.svm.SVC(gamma='scale', kernel='rbf', probability=True)
clf.fit(X_train, y_train)

# Compute Metrics
y_hat_test, metrics_dict = clf.predict(X_test), {}

metrics_dict['accuracy_score'] = sklearn.metrics.accuracy_score(y_test, y_hat_test)

View Tracked Data

Visit Newron dashboard to view the tracked data. You can also share the dashboard with your team to collaborate on the project*. Click here to view the dashboard

Newron also allows you to track custom hyperparameters and metrics. NB: if custom logging is used, newron.end_run() is needed to finish that particular run.

#import all the required ML packages
import pandas as pd
import numpy as np
import sklearn
from sklearn import datasets, model_selection, svm, metrics

#import newron sdk to your code
import newron

#lets disable the autolog
newron.sklearn.autolog(disable=True)


# Load and Prep Data
iris = sklearn.datasets.load_iris()
X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(iris.data,  iris.target, test_size=0.2)

# Model Training
clf = sklearn.svm.SVC(gamma='scale', kernel='rbf', probability=True)


clf.fit(X_train, y_train)
newron.log_params(clf.get_params())
# Compute Metrics
y_hat_test, metrics_dict = clf.predict(X_test), {}

metrics_dict['accuracy_score'] = sklearn.metrics.accuracy_score(y_test, y_hat_test)

#log_metrics takes a dictionary of paramers as input
newron.log_metrics(metrics_dict)

newron.sklearn.log_model(clf,"sklearn_iris_clf")

# To finish tracking after custom logging, explicit call to end_run is needed
newron.end_run()

Autologging along with custom logging

If one wants to use autolog as well as log custom parameters and (or) custom metrics within the code, start_run should be used, see in the following example:

#import all the required ML packages
import pandas as pd
import numpy as np
import sklearn
from sklearn import datasets, model_selection, svm, metrics

import newron



with newron.start_run():
  # Load and Prep Data
  iris = sklearn.datasets.load_iris()
  X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(iris.data,  iris.target, test_size=0.2)
  newron.sklearn.autolog()
  # Model Training
  clf = sklearn.svm.SVC(gamma='scale', kernel='rbf', probability=True)
  clf.fit(X_train, y_train)

  # using the with context, automatically ends run when it exits
  #with newron.start_run() as run:

  clf = sklearn.svm.SVC(gamma='scale', kernel='rbf', probability=True)
  clf.fit(X_train, y_train)

  # Compute Metrics
  y_hat_test, metrics_dict = clf.predict(X_test), {}

  metrics_dict['accuracy_score'] = sklearn.metrics.accuracy_score(y_test, y_hat_test)

  newron.log_param('kernel1','rbf')

  newron.log_metrics(metrics_dict)

Compare different runs

Logged runs are displayed in the Newron dashboard of the user. Newron organizes all of your runs as part of the experiment and experiments are contained within projects.