Creating a basic project

In this tutorial, we will demonstrate how you can create a project and log a single experiment.

import json

import pandas as pd
from sklearn.datasets import make_classification
from sklearn.svm import SVC

from lazyscribe import Project

First, let’s create some toy data for the experiment.

X, y = make_classification(n_samples=1000, n_features=10)

Next, create the project and run the model fit

project = Project(fpath="project.json", author="The Best")
with project.log(name="Base performance") as exp:
    model = SVC(kernel="linear")
    model.fit(X, y)
    exp.log_metric("score", model.score(X, y))
    exp.log_parameter("features", list(range(10)))

Finally, let’s print and view the experiment data.

print(json.dumps(list(project), indent=4, sort_keys=True))
[
    {
        "artifacts": [],
        "author": "The Best",
        "created_at": "2025-03-14T14:41:13",
        "dependencies": [],
        "last_updated": "2025-03-14T14:41:13",
        "last_updated_by": "The Best",
        "metrics": {
            "score": 0.885
        },
        "name": "Base performance",
        "parameters": {
            "features": [
                0,
                1,
                2,
                3,
                4,
                5,
                6,
                7,
                8,
                9
            ]
        },
        "short_slug": "base-performance",
        "slug": "base-performance-20250314144113",
        "tags": [],
        "tests": []
    }
]

You can also represent the project in a table:

experiments, tests = project.to_tabular()

df = pd.DataFrame(experiments)
df.columns = pd.MultiIndex.from_tuples(df.columns)
df.head()
name slug short_slug author created_at last_updated last_updated_by metrics
score
0 Base performance base-performance-20250314144113 base-performance The Best 2025-03-14T14:41:13 2025-03-14T14:41:13 The Best 0.885


Then, you can call lazyscribe.Project.save() to save the output JSON.

Total running time of the script: (0 minutes 1.075 seconds)

Gallery generated by Sphinx-Gallery