-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathdatabricks_notebook.py
94 lines (52 loc) · 1.7 KB
/
databricks_notebook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Databricks notebook source
# MAGIC %md
# MAGIC # MLflow Regression Recipe Databricks Notebook
# MAGIC This notebook runs the MLflow Regression Recipe on Databricks and inspects its results.
# MAGIC
# MAGIC For more information about the MLflow Regression Recipe, including usage examples,
# MAGIC see the [Regression Recipe overview documentation](https://mlflow.org/docs/latest/recipes.html#regression-recipe)
# MAGIC and the [Regression Recipe API documentation](https://mlflow.org/docs/latest/python_api/mlflow.recipes.html#module-mlflow.recipes.regression.v1.recipe).
# COMMAND ----------
# MAGIC %pip install -r ../../requirements.txt
dbutils.library.restartPython()
# COMMAND ----------
# MAGIC %md ### Start with a recipe:
# COMMAND ----------
from mlflow.recipes import Recipe
r = Recipe(profile="databricks")
# COMMAND ----------
r.clean()
# COMMAND ----------
# MAGIC %md ### Inspect recipe DAG:
# COMMAND ----------
r.inspect()
# COMMAND ----------
# MAGIC %md ### Ingest the dataset:
# COMMAND ----------
r.run("ingest")
# COMMAND ----------
# MAGIC %md ### Split the dataset into train, validation and test:
# COMMAND ----------
r.run("split")
# COMMAND ----------
r.run("transform")
# COMMAND ----------
# MAGIC %md ### Train the model:
# COMMAND ----------
r.run("train")
# COMMAND ----------
# MAGIC %md ### Evaluate the model:
# COMMAND ----------
r.run("evaluate")
# COMMAND ----------
# MAGIC %md ### Register the model:
# COMMAND ----------
r.run("register")
# COMMAND ----------
r.inspect("train")
# COMMAND ----------
training_data = r.get_artifact("training_data")
training_data.describe()
# COMMAND ----------
trained_model = r.get_artifact("model")
print(trained_model)