newron.sklearn.log_model()


newron.sklearn.log_model(model, artifact_path)

Enables (or disables) and configures data logging from sklearn to newron. Logs loss and any other metrics specified in the fit function, and optimizer data as parameters. Model checkpoints are logged as artifacts to a ‘models’ directory.

Parameters -

  • model - It denotes the model developed by the user
  • artifact_path - It denotes the directory in artifact_uri to write to

Example

import pandas as pd
import numpy as np
import sklearn
from sklearn import datasets, model_selection, svm, metrics

import newron

newron.init("demo_iris_3")

newron.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)


newron.sklearn.autolog()

# log models for scikit learn framewor
#import mlflow
newron.sklearn.log_model(clf,"sklearn_iris_clf")

# 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.sklearn.log_model(clf,"sklearn_iris_clf")

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

newron.log_metrics(metrics_dict)

metrics_dict

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