Adapt Model Training
Target file: notebooks/2_model_training_and_deployment/model_training.ipynb
Target job: resources/2_1_model_training_job.yml
When to use
Use this skill whenever the user wants to:
- Swap
DecisionTreeClassifier for a different algorithm.
- Change the problem type (regression, clustering, forecasting, …).
- Change features, target column, or evaluation metric.
- Rename the registered model in Unity Catalog.
Step-by-step
Pick the algorithm for the problem type.
- Regression:
LinearRegression, XGBRegressor, LGBMRegressor,
RandomForestRegressor, etc.
- Classification:
RandomForestClassifier, LogisticRegression,
XGBClassifier, etc.
- Clustering:
KMeans, DBSCAN, etc. — note: no target column.
- Forecasting: Prophet, ARIMA, or DL approaches.
Update features and target. Match the columns produced by the
adapted data ingestion notebook. For clustering, drop the target
variable and any train/test split that depends on it.
Update logged metrics. Choose metrics appropriate to the problem
type:
- Regression →
rmse, mae, r2.
- Classification →
accuracy, f1, precision, recall, roc_auc.
- Clustering →
silhouette_score, davies_bouldin_score.
Update best-run selection. Change selected_metric to the metric you
actually optimize, and flip the direction (maximize vs minimize)
accordingly.
Rename the registered model. Update model_name (currently
iris_model) and keep the three-level reference
{catalog_name}.{schema_name}.<model_name>.
Keep the Challenger alias. Register every new training run with the
@challenger alias. The deployment pipeline will promote it to
@champion later. Do not write @champion from the training notebook.
Let the signature stay inferred. mlflow.models.infer_signature is
driven by the X_train / y_train you pass in — just make sure they are
representative.
Sync the training job YAML. Update
resources/2_1_model_training_job.yml:
- Task
notebook_path if you rename the notebook.
base_parameters if you add new widgets.
email_notifications.on_failure to the team's address.
Parameterization contract
Keep widgets for catalog_name and schema_name. The MLflow experiment
should remain user-scoped — /{user}/{model}_{catalog} — to avoid
collisions when multiple developers train in parallel. See
mlops-quickstart-overview for the full contract.
Edge cases
- Clustering: remove evaluation steps that depend on a target column
(e.g. accuracy). Use unsupervised metrics like silhouette score.
- Imbalanced classification: log
f1_weighted or roc_auc instead of
raw accuracy; consider class weights or resampling.
- Forecasting with seasonality: log the model artifact plus a holdout
forecast plot. Track both point metrics (RMSE) and percentile errors
(MAPE, sMAPE).
- Hyperparameter search: wrap runs inside a parent MLflow run and rely
on the existing best-run selection logic to pick the registered version.
- Deep learning: log the model with
mlflow.pyfunc or framework-native
flavor (mlflow.pytorch, mlflow.tensorflow) — the rest of the pipeline
is flavor-agnostic.
1---2name: adapt-model-training3description: Adapt the MLOps Quickstart model training notebook from the Iris classifier placeholder to a custom algorithm and problem type (regression, clustering, classification, forecasting). Use when the user wants to change the model, features, target, metrics, or registered model name, or when they ask how to fit a different ML problem into this template.4---56# Adapt Model Training78Target file: `notebooks/2_model_training_and_deployment/model_training.ipynb`9Target job: `resources/2_1_model_training_job.yml`1011## When to use1213Use this skill whenever the user wants to:1415- Swap `DecisionTreeClassifier` for a different algorithm.16- Change the problem type (regression, clustering, forecasting, …).17- Change features, target column, or evaluation metric.18- Rename the registered model in Unity Catalog.1920## Step-by-step21221. **Pick the algorithm for the problem type.**23 - **Regression**: `LinearRegression`, `XGBRegressor`, `LGBMRegressor`,24 `RandomForestRegressor`, etc.25 - **Classification**: `RandomForestClassifier`, `LogisticRegression`,26 `XGBClassifier`, etc.27 - **Clustering**: `KMeans`, `DBSCAN`, etc. — note: no target column.28 - **Forecasting**: Prophet, ARIMA, or DL approaches.29302. **Update `features` and `target`.** Match the columns produced by the31 adapted data ingestion notebook. For clustering, drop the `target`32 variable and any train/test split that depends on it.33343. **Update logged metrics.** Choose metrics appropriate to the problem35 type:36 - Regression → `rmse`, `mae`, `r2`.37 - Classification → `accuracy`, `f1`, `precision`, `recall`, `roc_auc`.38 - Clustering → `silhouette_score`, `davies_bouldin_score`.39404. **Update best-run selection.** Change `selected_metric` to the metric you41 actually optimize, and flip the direction (`maximize` vs `minimize`)42 accordingly.43445. **Rename the registered model.** Update `model_name` (currently45 `iris_model`) and keep the three-level reference46 `{catalog_name}.{schema_name}.<model_name>`.47486. **Keep the Challenger alias.** Register every new training run with the49 `@challenger` alias. The deployment pipeline will promote it to50 `@champion` later. Do not write `@champion` from the training notebook.51527. **Let the signature stay inferred.** `mlflow.models.infer_signature` is53 driven by the `X_train` / `y_train` you pass in — just make sure they are54 representative.55568. **Sync the training job YAML.** Update57 `resources/2_1_model_training_job.yml`:58 - Task `notebook_path` if you rename the notebook.59 - `base_parameters` if you add new widgets.60 - `email_notifications.on_failure` to the team's address.6162## Parameterization contract6364Keep widgets for `catalog_name` and `schema_name`. The MLflow experiment65should remain user-scoped — `/{user}/{model}_{catalog}` — to avoid66collisions when multiple developers train in parallel. See67`mlops-quickstart-overview` for the full contract.6869## Edge cases7071- **Clustering**: remove evaluation steps that depend on a target column72 (e.g. accuracy). Use unsupervised metrics like silhouette score.73- **Imbalanced classification**: log `f1_weighted` or `roc_auc` instead of74 raw accuracy; consider class weights or resampling.75- **Forecasting with seasonality**: log the model artifact plus a holdout76 forecast plot. Track both point metrics (RMSE) and percentile errors77 (MAPE, sMAPE).78- **Hyperparameter search**: wrap runs inside a parent MLflow run and rely79 on the existing best-run selection logic to pick the registered version.80- **Deep learning**: log the model with `mlflow.pyfunc` or framework-native81 flavor (`mlflow.pytorch`, `mlflow.tensorflow`) — the rest of the pipeline82 is flavor-agnostic.