# Mlflow integration with Dask-SQL machine learning

**URL:** https://dask.discourse.group/t/mlflow-integration-with-dask-sql-machine-learning/2146
**Category:** Distributed
**Created:** [August 23, 2023, 7:17am UTC](https://dask.discourse.group/t/mlflow-integration-with-dask-sql-machine-learning/2146 "2023-08-23T07:17:20Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Nirajkanth](https://avatars.discourse-cdn.com/v4/letter/n/58956e/32.png) [@Nirajkanth](https://dask.discourse.group/u/Nirajkanth)
#### Post date: [August 23, 2023, 7:17am UTC](https://dask.discourse.group/t/mlflow-integration-with-dask-sql-machine-learning/2146/1 "2023-08-23T07:17:20Z")

</div>

Hi all,  
I am trying to integrate mlflow with dask-sql machine learning in a distributed cluster, however I could not find any documentation on that.

I found that, it is possible to export the trained model as mlflow format, but my concern is whether we can use mlflow to track and compare multiple models as we do in usual ml in python.

Please add your commands on this.

Thanks in advance

---

<div class="post-metadata">

### Author: ![guillaumeeb](https://yyz1.discourse-cdn.com/flex035/user_avatar/dask.discourse.group/guillaumeeb/32/1613_2.png) [@guillaumeeb](https://dask.discourse.group/u/guillaumeeb)
#### Post date: [August 23, 2023, 3:18pm UTC](https://dask.discourse.group/t/mlflow-integration-with-dask-sql-machine-learning/2146/2 "2023-08-23T15:18:43Z")

</div>

Hi @Nirajkanth,

It is not very clear to me what you are trying to do.

I’ve found this resource on internet with a quick search:

> **[Hyperparameter tuning with Dask Distributed and MLflow](https://medium.com/@chiefhustler/hyperparameter-tuning-with-dask-distributed-and-mlflow-ca6a4a275a2e)**
>
> In this post, we build a machine learning model, tune hyperparameters in the cloud with Dask-distributed, and log our experiment with…

Does it correspond to what you are after?

---

<div class="post-metadata">

### Author: ![Nirajkanth](https://avatars.discourse-cdn.com/v4/letter/n/58956e/32.png) [@Nirajkanth](https://dask.discourse.group/u/Nirajkanth)
#### Post date: [August 24, 2023, 2:47am UTC](https://dask.discourse.group/t/mlflow-integration-with-dask-sql-machine-learning/2146/3 "2023-08-24T02:47:46Z")

</div>

Hi @guillaumeeb  
I also looked that article form the internet. Actually he tried machine learning in python not in dask-sql.

I want similar to that in dask-sql only. I want to log all the models to mlflow as in the above article.  
My question is whether the dask-sql support such kind of mlflow model tracking ? so that I can log all the model details into the mlflow dashboard.

Thank you for your valuable time

---

<div class="post-metadata">

### Author: ![guillaumeeb](https://yyz1.discourse-cdn.com/flex035/user_avatar/dask.discourse.group/guillaumeeb/32/1613_2.png) [@guillaumeeb](https://dask.discourse.group/u/guillaumeeb)
#### Post date: [August 24, 2023, 9:56am UTC](https://dask.discourse.group/t/mlflow-integration-with-dask-sql-machine-learning/2146/4 "2023-08-24T09:56:53Z")

</div>

Do you have some example code of your workflow using `dask-sql`?

I don’t think you’ll be able to use MLFlow within `dask-sql` without injecting some Python code. But you should be able to mix `dask-sql` with other Dask interfaces.

---

<div class="post-metadata">

### Author: ![Nirajkanth](https://avatars.discourse-cdn.com/v4/letter/n/58956e/32.png) [@Nirajkanth](https://dask.discourse.group/u/Nirajkanth)
#### Post date: [August 25, 2023, 2:57am UTC](https://dask.discourse.group/t/mlflow-integration-with-dask-sql-machine-learning/2146/5 "2023-08-25T02:57:56Z")

</div>

This is the code that I want to track with mlflow.

query = “”"  
CREATE EXPERIMENT my\_exp WITH (  
model\_class = ‘sklearn.ensemble.GradientBoostingClassifier’,  
experiment\_class = ‘sklearn.model\_selection.GridSearchCV’,  
tune\_parameters = (n\_estimators = ARRAY [16, 32, 2],  
learning\_rate = ARRAY [0.1,0.01,0.001],  
max\_depth = ARRAY [3,4,5,10]  
),  
target\_column = ‘target’  
) AS (  
SELECT sepal\_length, sepal\_width, petal\_length, petal\_width,  
CASE  
WHEN species = ‘Iris-setosa’ THEN 0  
WHEN species = ‘Iris-versicolor’ THEN 1  
WHEN species = ‘Iris-virginica’ THEN 2  
END AS target  
FROM flower1  
LIMIT 100  
)  
“”"  
result1 = c.sql(query)

c.sql(“”"  
SELECT \* FROM PREDICT (  
MODEL my\_exp,  
SELECT sepal\_length, sepal\_width, petal\_length, petal\_width,  
CASE  
WHEN species = ‘Iris-setosa’ THEN 0  
WHEN species = ‘Iris-versicolor’ THEN 1  
WHEN species = ‘Iris-virginica’ THEN 2  
END AS actual  
FROM flower1  
OFFSET 100  
)  
“”").compute()  
I could not find a document/resource to include mlflow tracking to this code?

---

<div class="post-metadata">

### Author: ![guillaumeeb](https://yyz1.discourse-cdn.com/flex035/user_avatar/dask.discourse.group/guillaumeeb/32/1613_2.png) [@guillaumeeb](https://dask.discourse.group/u/guillaumeeb)
#### Post date: [August 25, 2023, 3:43pm UTC](https://dask.discourse.group/t/mlflow-integration-with-dask-sql-machine-learning/2146/6 "2023-08-25T15:43:15Z")

</div>

Thanks, I was not even aware there was such a functionality in `dask-sql`!

You might be achieve what is in the linked post above with [custom functions](https://dask-sql.readthedocs.io/en/latest/custom.html), but honestly, I think if you really want an MLFlow integration, you probably should use plain Dask Python code instead of `dask-sql`. I don’t think there is any example of integrating MLFlow in `dask-sql` as of now.

---

<div class="post-metadata">

### Author: ![Nirajkanth](https://avatars.discourse-cdn.com/v4/letter/n/58956e/32.png) [@Nirajkanth](https://dask.discourse.group/u/Nirajkanth)
#### Post date: [August 27, 2023, 3:34am UTC](https://dask.discourse.group/t/mlflow-integration-with-dask-sql-machine-learning/2146/7 "2023-08-27T03:34:15Z")

</div>

Thanks a lot for the clarification.
