在 GitHub 上编辑

scikit-learn

DVCLive 可以为您的 Scikit-learn 项目添加实验跟踪功能。

用法

您需要创建一个 Live 实例,并调用 记录数据 的方法。

DVCLive 提供了内置函数来生成 scikit-learn 图表,请参见 Live.log_sklearn_plot()

以下代码片段来自上述链接的 Colab 笔记本:

from dvclive import Live

...

with Live() as live:

    live.log_param("n_estimators", n_estimators)

    clf = RandomForestClassifier(n_estimators=n_estimators)
    clf.fit(X_train, y_train)

    y_train_pred = clf.predict(X_train)

    live.log_metric("train/f1", f1_score(y_train, y_train_pred, average="weighted"), plot=False)
    live.log_sklearn_plot(
        "confusion_matrix", y_train, y_train_pred, name="train/confusion_matrix",
        title="Train Confusion Matrix")

    y_test_pred = clf.predict(X_test)

    live.log_metric("test/f1", f1_score(y_test, y_test_pred, average="weighted"), plot=False)
    live.log_sklearn_plot(
        "confusion_matrix", y_test, y_test_pred, name="test/confusion_matrix",
        title="Test Confusion Matrix")
内容

🐛 发现问题?告诉我们!或者修复它:

在 GitHub 上编辑

有疑问?加入我们的聊天,我们会为您提供帮助:

Discord 聊天