Databricks ML Professional cheat sheet
Databricks ML Professional · Keep the key ideas within reach.
Model Development
Feature Store: create_feature_table writes a Delta table keyed by primary keys plus a timestamp key; publish_table creates an online store for low-latency lookup; training sets are built with create_training_set using a FeatureLookup per feature table.
FeatureLookup requires table_name, lookup_key (must match the training DataFrame column), and feature_names; rename_outputs maps stored feature names to training column names, and a default value applies when a lookup misses.
MLflow autologging for scikit-learn, XGBoost, and PyTorch is enabled per flavor (e.g., mlflow.sklearn.autolog()); it logs params, metrics, and model artifacts but disables itself if a run is already active unless log_models is configured.
Hyperparameter tuning: Hyperopt fmin with an MLflow-trials SparkTrials for distributed search; the objective returns a loss to minimize, and best parameters are read from fmin's returned dict.
Custom Python models use mlflow.pyfunc.PythonModel with predict(self, context, model_input); the context carries artifacts loaded in load_context, which runs once per model load.
Signature inference: mlflow.models.infer_signature(input_sample, output) records column names and dtypes; a signature enforces schema at serving time and rejects mismatched payloads.
Model registry stages: None, Staging, Production, Archived; transitions use transition_model_version_stage and can archive existing versions with archive_existing_versions=True.
Unity Catalog model naming is catalog.schema.model; a registered model version URI is models:/catalog.schema.model/version, while the workspace registry uses models:/name/version.
ML Ops
MLflow run hierarchy: experiment contains runs; each run has run_id, params, metrics (with step and timestamp), tags, and artifacts; metrics are append-only per step, so the last value wins for a given key and step.
Model version states: PendingRegistration -> Ready when registration succeeds; a failed registration leaves the version in FailedRegistration and it cannot be served.
Webhooks on the model registry fire on events such as MODEL_VERSION_CREATED and MODEL_VERSION_TRANSITIONED_STAGE, enabling CI/CD triggers when a version enters Production.
Job scheduling: Databricks jobs support cron schedules and continuous triggers; job clusters terminate after the run, while all-purpose clusters persist and bill until terminated.
Delta Lake time travel reads a prior table version with VERSION AS OF or TIMESTAMP AS OF; restore recovers a table to an earlier version, supporting reproducible training data.
Automatic model lineage in Unity Catalog links a model version to the runs, notebooks, and tables that produced it; lineage is captured when the model is logged from a tracked run.
Model evaluation on a held-out slice should be logged as metrics with distinct keys per slice (e.g., f1_slice_A) so comparisons across runs remain queryable in the MLflow UI.
Drift monitoring compares a baseline profile (e.g., mean, std per feature) against recent inference data; Databricks Lakehouse Monitoring creates profile and drift metrics tables for this comparison.
Model Deployment
Model Serving endpoints host a registered model version or a served entity; scale-to-zero is available on serverless endpoints, and provisioned concurrency controls warm capacity.
Serving endpoint query: POST to the endpoint URL with a JSON body containing dataframes_records or dataframe_split; the response echoes predictions in the same format.
Serving a pyfunc model requires a signature for schema validation; without a signature the endpoint accepts arbitrary JSON and validation is the model's responsibility.
Batch inference patterns: Spark UDF with mlflow.pyfunc.load_model wrapped in mlflow.pyfunc.spark_udf, or pandas function API applied to a Delta table and written back with merge.
Model version routing: an endpoint can serve a specific version or follow the Production stage alias; changing the served version does not require endpoint recreation when using alias-based config.
Environment reproducibility: conda_env or pip_requirements pinned at log time is rebuilt at serve time; mismatched dependency versions are a common cause of endpoint deployment failure.
Permission model: endpoint access is governed by endpoint permissions, and model access by Unity Catalog privileges (EXECUTE on the model, USE on schema); both are required for a caller.
Streaming deployment: a Structured Streaming job reading from a Delta or Kafka source and writing predictions to a sink provides continuous inference with checkpoint-based exactly-once guarantees.