# Hello World ML on Databricks
import mlflow
import mlflow.sklearn
from mlflow.models import infer_signature
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
# 1. Load toy data
X, y = load_iris(return_X_y=True, as_frame=True)
# 2. Train a tiny model
model = LogisticRegression(max_iter=100).fit(X, y)
preds = model.predict(X)
# 3. Set experiment (will auto-create if not present)
mlflow.set_experiment("/Shared/hello_world_exp")
# 4. Log model with signature + input_example
with mlflow.start_run():
sig = infer_signature(X, preds)
mlflow.sklearn.log_model(
sk_model=model,
artifact_path="model",
signature=sig,
input_example=X.head(3),
registered_model_name="hello_world_model"
)
Code language: PHP (php)
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at Cotocus. I share tech blog at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow , and SEO strategies at Wizbrand.
Do you want to learn Quantum Computing?
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at WIZBRAND