Addestrare e registrare nel registry
Esegua l'addestramento e registri il modello risultante.
Addestrare e registrare nel registry è una lezione MLOps Academy gratuita su CoddyKit. Questa è la lezione 1 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento MLOps Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso MLOps Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
One Run, Fully Captured
This lesson ties training and the registry together. You train a model, then push it into the MLflow Model Registry so it becomes a versioned, reusable artifact. 🚀
Start a Tracking Run
Wrap your training in mlflow.start_run(). Everything you log inside that block belongs to one run, with its own id and timestamp.
import mlflow
with mlflow.start_run() as run:
# train and log here
print(run.info.run_id)Train Your Model
Inside the run, fit your estimator like normal. The training code does not change just because MLflow is watching.
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(n_estimators=100)
model.fit(X_train, y_train)Log the Parameters
Record the choices you made with log_param. Months later, this is how you remember exactly which settings produced this model.
mlflow.log_param("n_estimators", 100)
mlflow.log_param("max_depth", None)Log the Metrics
Capture how well it did with log_metric. Metrics are the numbers you will sort by when comparing runs later.
acc = model.score(X_test, y_test)
mlflow.log_metric("accuracy", acc)Log the Model Artifact
Use mlflow.sklearn.log_model to save the fitted model into the run. MLflow stores the weights, flavor, and environment together.
mlflow.sklearn.log_model(
sk_model=model,
name="model",
)Register While Logging
Pass registered_model_name and MLflow logs the model and registers a new version in one step. This is the cleanest path.
mlflow.sklearn.log_model(
sk_model=model,
name="model",
registered_model_name="churn-classifier",
)Register After the Fact
Already logged a model? Call register_model with the run URI to add it to the registry without retraining anything.
uri = "runs:/<run_id>/model"
mlflow.register_model(uri, "churn-classifier")Versions Auto-Increment
Register the same name again and you get version 2, then 3, and so on. The registry keeps every version, never overwriting an old one.
Quick Check
You log a model under a name that already exists. What happens?
The Run, Confirmed
After the block exits, the run is marked FINISHED. Your params, metrics, and registered model version are now permanently linked.
Find It in the UI
Open the MLflow UI and your run appears under its experiment, with the new model version listed in the Models tab. Nothing is lost.
Recap: Train, Log, Register
You trained inside a run, logged params and metrics, saved the model, and registered a version. Train, log, register: that is the start of a real pipeline. ✅
Domande Frequenti
La lezione «Addestrare e registrare nel registry» è gratuita?
Sì — il testo completo di «Addestrare e registrare nel registry» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso MLOps Academy, passa a CoddyKit PRO. Il corso MLOps Academy include 4 lezioni in totale.
Cosa imparerò in «Addestrare e registrare nel registry»?
Esegua l'addestramento e registri il modello risultante. Eserciti MLOps Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare MLOps Academy?
Non è richiesta alcuna esperienza precedente. MLOps Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 1 di 4.
Quanto tempo richiede la lezione «Addestrare e registrare nel registry»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione MLOps Academy?
Sì. Ogni lezione MLOps Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Addestrare e registrare nel registry
- Promuovere il modello migliore in Production
- Servire il modello in Production
- Tracciare un round trip di previsione