/fabric-data-science:model-train <classification|regression|clustering> --algorithm <algo> [--autolog]from fabric-data-science
Generates a Fabric notebook for training an ML model with MLflow tracking, evaluation metrics, and run comparison.
Ships in fabric-data-science. Installing the plugin adds it to Claude Code.
Generate a Fabric notebook that trains a model, logs everything to MLflow, and evaluates performance.
<type> — One of: classification, regression, clustering. Ask if not provided.--algorithm — Algorithm to use. Ask if not provided. Options by type:
logistic-regression, random-forest, lightgbm, xgboost, svmlinear-regression, random-forest, lightgbm, xgboost, gradient-boostingkmeans, dbscan, gaussian-mixture--autolog — Enable MLflow autologging instead of manual logging.Cell 1: Imports and setup
Import the appropriate libraries based on --algorithm:
from sklearn.<module> import <Model>from lightgbm import LGBMClassifier / LGBMRegressorfrom xgboost import XGBClassifier / XGBRegressorAlways import:
import mlflow
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import *
Cell 2: Enable autologging (when --autolog)
mlflow.autolog() # or mlflow.sklearn.autolog(), mlflow.lightgbm.autolog()
Cell 3: Load and prepare data
Load from lakehouse, split into train/test, apply preprocessing.
Cell 4: Train model
Generate the model training code with all relevant hyperparameters exposed as variables:
with mlflow.start_run(run_name="<algorithm>-v1"):
# Hyperparameters
params = {
# ... algorithm-specific params
}
mlflow.log_params(params)
model = <ModelClass>(**params)
model.fit(X_train, y_train)
Cell 5: Evaluate
For classification:
y_pred = model.predict(X_test)
mlflow.log_metric("accuracy", accuracy_score(y_test, y_pred))
mlflow.log_metric("f1_weighted", f1_score(y_test, y_pred, average="weighted"))
mlflow.log_metric("precision_weighted", precision_score(y_test, y_pred, average="weighted"))
mlflow.log_metric("recall_weighted", recall_score(y_test, y_pred, average="weighted"))
For regression:
y_pred = model.predict(X_test)
mlflow.log_metric("rmse", np.sqrt(mean_squared_error(y_test, y_pred)))
mlflow.log_metric("mae", mean_absolute_error(y_test, y_pred))
mlflow.log_metric("r2", r2_score(y_test, y_pred))
For clustering:
labels = model.predict(X)
mlflow.log_metric("silhouette", silhouette_score(X, labels))
mlflow.log_metric("calinski_harabasz", calinski_harabasz_score(X, labels))
Cell 6: Log model and artifacts
mlflow.sklearn.log_model(model, "model")
# Feature importance (tree-based models)
if hasattr(model, "feature_importances_"):
importance_df = pd.DataFrame({
"feature": FEATURE_COLS,
"importance": model.feature_importances_
}).sort_values("importance", ascending=False)
importance_df.to_csv("/tmp/feature_importance.csv", index=False)
mlflow.log_artifact("/tmp/feature_importance.csv")
Cell 7: Visualizations
Generate appropriate plots:
Log plots as artifacts via mlflow.log_artifact().
Show the user:
/model-register to register the best model.What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
6 commands in this plugin
/experiment-createCreate a new MLflow experiment in Fabric with tracking configuration and initial notebook scaffold/fabric-ds-setupSet up the Fabric Data Science plugin — configure workspace, lakehouse connection, and install Python ML libraries/model-predictGenerate batch scoring code using PREDICT function or MLflow model loadingnpx claudepluginhub thelobbi/claude-m --plugin fabric-data-scienceOther plugins' commands for the same job