See how one well-framed prompt at each stage takes a raw dataset from a single-notebook experiment to a tuned, explainable, monitored production ML system on Databricks.
Building a machine learning model is only one part of putting ML into production. Data scientists also need to engineer features, track experiments, deploy models, automate pipelines and monitor performance over time. Managing these interconnected workflows requires significant engineering effort, often across multiple tools.
Genie Code helps data scientists work across the ML lifecycle using natural language. With access to Databricks tools and workspace context, it can help developers explore data, build models, identify potential issues and set up the infrastructure needed to deploy and operate them. Instead of manually connecting every component, developers can guide Genie Code through the workflow, review its decisions and iterate as they go.
In this post, we'll demonstrate that process using a loan default prediction model. Starting with a raw dataset, we'll use Genie Code to move through three stages: crawl (build a working model), walk (improve and deploy it) and run (automate retraining and monitor model health). Along the way, you'll see Genie Code act as a design partner for modeling and architecture choices, not just a code generator.
Genie Code brings AI-assisted development to the Databricks Platform, combining coding capabilities with an understanding of your organization's data and business context. Powered by Genie Ontology, it can use context from Unity Catalog and your workspace to understand what data means, how assets relate and what's already been built. This helps Genie Code make more informed recommendations based on your specific environment rather than generating code in isolation.
Genie Code also works across Databricks ML capabilities, including MLflow, Feature Store and Model Serving. This allows developers to build on their work as they move from experimentation to deployment and monitoring, rather than treating each stage as a separate project.
Throughout the process, data scientists stay in control. They can inspect generated code, validate decisions and refine the workflow as requirements evolve.

We'll do this with a crawl, walk, run progression:
We're using raw Lending Club loan data that ships with every Databricks workspace (in samples/databricks/datasets/lending-club-loan-stats). Lending Club is a consumer lending marketplace. We'll use its sample loan data to train a binary classifier that predicts whether a borrower will default. The dataset contains 145 columns, including information that could introduce target leakage if used without careful feature selection.
Before writing a line of modeling code, it’s a good idea to take a second and survey what’s already in your workspace. Genie Code has access to Unity Catalog, your existing notebooks, and an entire graph ontology of trusted assets in the platform, which means it can tell you what's already been built for a problem like yours. A simple prompt like this is a great way to start:
I want to build a classifier to predict loan defaults. Are there existing features or tables I could reuse, any pipelines that already clean or augment lending data, or any registered models or notebooks that tackle a similar problem?
In larger-scale projects, taking the time to do this initial exploration can save days of work. Genie Code can surface Feature Views you can reuse instead of rebuilding, augmentation pipelines already running on similar data, and even models that already solve a comparable problem. For this walkthrough, we'll build the workflow from scratch rather than reuse existing assets, but checking what's already available is a useful first step when working with your own data.
Genie Code prompt:
I have raw Lending Club loan data in /Volumes/samples/databricks/datasets/lending-club-loan-stats/. I want to build a binary classifier that predicts whether a borrower will default. Can you explore the data, engineer a proper label from the loan status field, clean up features that wouldn't be available at prediction time or are leaky, and then fit a few models to find the best one? Log everything to MLflow so I can compare runs. Use insert_catalog_here for any tables you write.
That's it. Don’t forget to insert your catalog. I’ll walk through what it produced. If you’d like to follow along with the code, I put all of the assets and prompts in a repo here.
The table below shows six loan statuses in the sample:
Status | Count | What it means |
Current | 122,469 | Loan is active, outcome unknown |
Fully Paid | 5,660 | Borrower repaid in full |
In Grace Period | 1,062 | Payment due recently, could go either way |
Late (31-120 days) | 1,032 | Seriously delinquent |
Late (16-30 days) | 415 | Delinquent |
Charged Off | 134 | Written off as a loss |
If you just slap a classifier on all 130k rows, you're making a critical mistake: "Current" loans haven't been resolved yet. You don't know if they'll default, so they are effectively unlabeled data.
Genie Code caught this immediately. It excluded "Current" and "In Grace Period" loans (ambiguous), and then created a mapping for the remaining columns. This illustrates how Genie Code can apply problem-specific reasoning to label engineering rather than relying on predefined modeling steps.
It is worth pointing out that with loan data like this, you would normally split train and test by time so you don't leak the future into the past. Since this sample is a single quarter of originations, there isn't enough of a window for a temporal split to mean much, and we split randomly instead. Genie Code is great at surfacing insights like this and can flag trade-offs instead of blindly acting.
It made similarly reasonable decisions for the many potential features in front of it. Of the 145 original columns, Genie Code identified and removed:
total_pymnt, recoveries, last_pymnt_d, etc.) - These exist because payments were made. At application time, they wouldn't exist.id, member_id, url) - No predictive value for tabular ML.Domain reasoning like this helps distinguish a usable model from a misleading one. Genie Code helped identify modeling decisions that could have undermined the results before training began, including unresolved labels and target leakage.
Genie Code built sklearn Pipelines with ColumnTransformer:
OrdinalEncoder for categoricals (trees split on values, ordering doesn't matter)OneHotEncoder + StandardScaler (linear models need the numeric separation)SimpleImputerWe can trace everything Genie Code did in our conversation.

As with any AI-generated code, it's important to execute and validate the results. You can also ask Genie Code to explain its decisions or revise its approach. Here, Genie Code trained three models and logged their results to MLflow, including confusion matrices and ROC curves, following established Databricks development patterns.

We've trained three models in a single notebook. Next, we'll add the feature management, tuning, interpretability and serving capabilities needed to move toward deployment.
To get there, we need:
Working with Genie Code is an iterative process. For complex tasks, it often helps to break the work into smaller steps, review the output and refine your instructions. Here, we'll combine several tasks into one prompt to demonstrate the workflow:
Genie Code prompt:
I built a basic loan default classifier in src/crawl/, but it needs to be production-quality. I want to split the next stage into three notebooks in src/walk/:
Feature engineering: set up a Feature View so my training and inference transformations stay in sync.
Training: run a hyperparameter search over the best model type from crawl, log all trials to MLflow.
Interpretability: in a separate notebook, load the best model from MLflow and run SHAP to explain its predictions
Use your_catalog_here.lending_club_walk for any feature views.
A common production ML failure is a model that receives differently transformed data at inference time than it saw during training. You clean a column one way in your training notebook, a different way in your serving pipeline, and suddenly your model cannot understand its input data.
Genie Code solved this by wrapping all feature logic in a single compute_loan_features() function and writing the cleaned output to a Delta source table. It then registered each feature column in Unity Catalog (Databricks' ColumnSelection pattern), keyed on loan_id. The registered feature definitions support governance and discoverability, while compute_loan_features() remains the source of truth for how the features are computed. Reusing these definitions across training and inference helps reduce the risk of training-serving skew. The benefit extends beyond this model: reusable, governed feature definitions help teams build on existing work rather than recreate feature logic for every project.

In the initial modeling stage, we used default hyperparameters, and Random Forest technically won in terms of AUC. But its recall was near zero, which is bad: it was barely flagging any defaults. Gradient boosting has far more headroom under proper tuning; that's the model we selected for further tuning. The model tuning notebook runs an Optuna hyperparameter optimization study over the HistGradientBoostingClassifier search space: learning rate, max depth, regularization strength, leaf sizes. With our best model, we attain the following results.
Metric | Initial Random Forest | Tuned gradient boosting |
Test AUC | 0.7074 | 0.7212 |
Test Recall | 0.0443 | 0.6215 |
Test F1 | 0.0831 | 0.4685 |
The tuned gradient boosting model improved AUC modestly, from 0.707 to 0.721. The larger gains were in recall and F1: recall increased from 4.4% to 62.2%, while F1 improved from 0.083 to 0.469 compared with the initial Random Forest baseline. These improvements came at the expense of some precision. The right trade-off for a lending model depends on the business costs of missed defaults and false positives.
While this is a vast improvement on our original attempt, this would be a great place to iterate further. Finding the best trade-off between false positive and false negative rates requires business judgment and is an area where talking to Genie Code about your goals can shine.
A model that performs well isn't enough in regulated industries. Lending models must be explainable. The interpretability notebook loads the best model from MLflow and runs SHAP (SHapley Additive exPlanations) on a 1,000-row sample.
The SHAP analysis reveals which features the model relies on most. Interest rate, loan grade, and revolving utilization dominate the global importance. This makes intuitive sense: borrowers with high interest rates already got flagged as riskier by Lending Club's own underwriting. The waterfall plots for individual predictions show exactly how each feature pushed a specific loan toward or away from a default prediction.

Much like the performance measures, plots get logged as artifacts on the same MLflow run as the model, keeping explanations and predictions together.
With our tuned model and SHAP analysis in place, the next step is to deploy a Model Serving endpoint for real-time inference.
Genie Code prompt:
Register the best model from the walk experiment to Unity Catalog and stand up a Model Serving endpoint so I can hit it with REST calls. Put the deployment notebook in src/walk/04_deployment. Also add a 05_sample_inference notebook that loads the endpoint and tests running a sample of predictions on it.
The deployment notebook does three things:
stablebox_catalog.lending_club_walk.loan_default_classifier v1)
The endpoint was provisioned in under 10 minutes. Once ready, scoring a loan is your pick between an SDK call and a REST API call:
Model Serving handles the serving infrastructure, so developers can deploy models behind a REST API without manually provisioning compute. Endpoints can scale to accommodate changing inference demand.
The final notebook grabs 20 random loans from the source table, sends them to the live endpoint, and compares predictions to actual outcomes.
With two prompts, we generated five notebooks. Compared with the initial Random Forest baseline, the selected and tuned gradient boosting model increased recall from about 4% to 62%. It's explainable, versioned in Unity Catalog, and serving predictions over REST.
Our model is now deployed and serving predictions, but operationalizing ML also requires maintaining its performance over time. Changes in data distributions and business conditions can affect model quality, making automated workflows and ongoing monitoring essential.
Genie Code prompt:
I want to wrap the walk stage into a Declarative Automation Bundle (DAB) so the whole pipeline runs as an automated Databricks job. Put the bundle config in src/run/. The job should:
Run feature engineering first
Then training (depends on step 1)
Then deployment (depends on step 2)
Also add a schedule so it retrains weekly. Use your_catalog_here.lending_club_walk for everything.
Genie Code produced a databricks.yml that connects the feature engineering, model training and deployment notebooks into an automated workflow with explicit dependencies:
The bundle also includes dev and prod targets, a weekly schedule (Monday at 6 AM), and email notifications on failure. Running databricks bundle deploy deploys the workflow configuration and resources. The scheduled job orchestrates the existing feature engineering, training and deployment notebooks with defined dependencies and failure notifications. Instead of manually configuring the orchestration, we used Genie Code to build on the notebooks created during experimentation and make their execution repeatable.
One caveat is that this example is configured to retrain and redeploy every week without a model promotion gate. In a real pipeline, a better configuration would have a validation step that scores the new model on a held-out set and only promotes it if it beats the current champion. For something high-stakes like credit risk, a human approval step before it goes live is also warranted. There is nothing stopping us from working through this logic with Genie Code, though I exclude the steps for brevity.
Genie Code prompt:
Last piece: I need to know when this model goes stale. Build a monitoring dashboard in src/run/ that shows model health, including prediction distribution over time, drift metrics, and the latest accuracy against a holdout set.
I want to see when the input data shifts enough that I should retrain. It should be incorporated in the DAB.
When inference logging is enabled, inference tables can capture serving requests and responses with associated metadata. Actual outcomes, when available, must be supplied and joined separately to assess model accuracy. In this walkthrough, the monitoring notebook uses synthetic timestamps to simulate a week of inference traffic for Data Quality Monitoring.
Changes in interest rates or the borrower population can cause data drift and may affect model performance. Monitoring helps identify changes that warrant investigation and potentially retraining.

Let's recap what we did in this post:
Stage | Notebooks | What it delivered | Assets |
|---|---|---|---|
Crawl | 1 | Label engineering, leakage removal, 3 trained models, MLflow tracking | |
Walk | 5 | Feature Views, Optuna tuning (14x recall), SHAP explanations, live REST endpoint | https://github.com/mpkrass7/ml-crawl-walk-run-with-genie-code/tree/master/src/walk |
Run | 1 + DAB config | Automated weekly retraining, daily drift monitoring, alerting | https://github.com/mpkrass7/ml-crawl-walk-run-with-genie-code/tree/master/src/run |
The walkthrough illustrates three practical benefits:
The result is a foundation for an operational ML system, built incrementally through natural-language prompts and developer review.
Explore the companion repository to follow the walkthrough in your own Databricks workspace. You can also apply the same crawl, walk, run approach to your own dataset and use Genie Code to build out each stage of the ML lifecycle.
Genie Code helps data scientists build and iterate on ML workflows using natural language. It can assist with data preparation, feature engineering, model training, evaluation and deployment using Databricks capabilities.
Yes. Genie Code can help generate workflows for model registration, deployment, automated retraining and monitoring. In this walkthrough, it creates a Declarative Automation Bundle to orchestrate the ML pipeline and configure a recurring schedule.
Genie Code can generate code that uses MLflow to track experiments, compare model performance, log artifacts and register trained models. This makes it easier to manage the transition from experimentation to deployment.
Genie Code can help developers create reusable feature definitions using Databricks Feature Views. Sharing feature definitions across training and inference helps reduce the risk of inconsistencies between the data used to develop a model and the data used to generate predictions.
The walkthrough demonstrates several important components of a production ML workflow, including model serving, automation and monitoring. Real-world deployments may also require additional validation, approval gates and governance controls, particularly for high-stakes applications.
Subscribe to our blog and get the latest posts delivered to your inbox.