Treine e registre no registro
Execute o treinamento e registre o modelo resultante.
Treine e registre no registro é uma aula grátis de MLOps Academy no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de MLOps Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de MLOps Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
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. ✅
Perguntas Frequentes
A aula “Treine e registre no registro” é grátis?
Sim — o texto completo de “Treine e registre no registro” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de MLOps Academy, atualize para CoddyKit PRO. O curso de MLOps Academy inclui 4 aulas no total.
O que vou aprender em “Treine e registre no registro”?
Execute o treinamento e registre o modelo resultante. Você pratica MLOps Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar MLOps Academy?
Nenhuma experiência prévia é necessária. MLOps Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.
Quanto tempo leva a aula “Treine e registre no registro”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de MLOps Academy?
Sim. Cada aula de MLOps Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Treine e registre no registro
- Promova o melhor modelo para Production
- Disponibilize o modelo de Production
- Rastreie uma ida e volta de previsão