Python package here: ml-clerk
What is ml-clerk?
ML-clerk, at its core, is a lightweight logging library that helps you keep track of performance, model parameters, timing (or whatever) throughout your data science experiment.
I’m a data scientist. Why should I care?
As a data scientist you’re constantly running new experiments. As you run new experiments, you are recording your results (if not, you should be recording your results). ML clerk does exactly that. It reduces the inertia by automatically recording the results of your experiment, so you don’t have to worry about keeping track.
Ok now that I’m convinced, where does ml-clerk log stuff?
ML clerk has two places where it tracks things - excel or google sheets. Excel setup is easier, so start with that. For google sheets usage, see the link below.
Training a model - demo purposes only
# Imports
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
= load_iris()
dataset
# Define data
= dataset['data']
X = dataset['target']
y
# Train the model
= LogisticRegression()
logistic_regression_classifier
logistic_regression_classifier.fit(X, y)
# Make predictions
= logistic_regression_classifier.predict(X)
predictions = logistic_regression_classifier.predict_proba(X) probabilities
Excel usage
#!/usr/bin/python
from ml_clerk import Clerk
# Set up the clerk with excel mode
= Clerk(excel_mode=True)
clerk
# file_path refers to the excel workbook you want to record in, and the sheet name referes to the sheet
= 'hello_world.xlsx'
FILE_PATH = 'Sheet1'
SHEET_NAME
=FILE_PATH, sheet_name=SHEET_NAME)
clerk.set_up(filepath
### Record all the artifacts in one go
=predictions, probabilities=probabilities, model_parameters=logistic_regression_classifier.get_params()) clerk.record(predictions
Google sheets usage
from ml_clerk import Clerk
# Set up the clerk with google sheets mode
= Clerk(google_sheets_mode=True)
clerk
# file_path refers to the excel workbook you want to record in, and the sheet name refers to the sheet
= '#your google sheets url'
GOOGLE_SHEETS_FILE_PATH = '#your sheet name'
SHEET_NAME
=GOOGLE_SHEETS_FILE_PATH, sheet_name=SHEET_NAME)
clerk.set_up(file_path
# Record all the artifacts in one go
clerk.record(=predictions,
predictions=probabilities,
probabilities=logistic_regression_classifier.get_params()
model_parameters )
Google sheets permissions
Follow this link for how to permission your Google account - py-gsheets.
Make sure you enable the Google sheets API under the project in Google console.
Update the
.env
with the path to token.json credentials file.