# Export Knime ML to Python Pickle

**URL:** <https://forum.knime.com/t/export-knime-ml-to-python-pickle/40419>\
**Category:** KNIME Extensions\
**Created:** [March 4, 2022, 9:02pm UTC](https://forum.knime.com/t/export-knime-ml-to-python-pickle/40419 "2022-03-04T21:02:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![TE499OP](https://forum-cdn.knime.com/user_avatar/forum.knime.com/te499op/32/37303_2.png) [@TE499OP](https://forum.knime.com/u/TE499OP)\
**Post date:** [March 4, 2022, 9:02pm UTC](https://forum.knime.com/t/export-knime-ml-to-python-pickle/40419/1 "2022-03-04T21:02:41Z")

</div>

Hello,

I am new to Knime. I created a ML workflow in Knime. My next step is to export the learning algorithm to a Python pickle file. I have read through all the documentation, but I cannot find the steps to export my Knime ML node to a Python pickle file.

Is it possible to create a Python pickle file from a Knime ML node?

Thanks,

Alex

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [March 4, 2022, 10:16pm UTC](https://forum.knime.com/t/export-knime-ml-to-python-pickle/40419/2 "2022-03-04T22:16:27Z")

</div>

@TE499OP if you use the knime python environment you can store the model as pickle.

> **[Simple example to make a random forest model with new Python Scrip in KNIME...](https://hub.knime.com/mlauber71/spaces/Public/kn_example_python_iris_2021~P6lVZYHup7PejexZ/current-state)**
>
> Simple example to make a random forest model with new Python Scrip in KNIME 4.5 using the iris dataset. Saving and reusing the model with Pickle Also creating …

Other than that you could use [PMML](https://forum.knime.com/t/export-pmml-that-outputs-class-probabilities/13244/2) or I very much like H2O.ai MOJO format to easily transfer models between KNIME, Python, R and Big Data systems:

> **[H2O.ai AutoML (wrapped with Python) in KNIME for classification problems –...](https://hub.knime.com/mlauber71/spaces/Public/automl/kn_automl_h2o_classification_python~MuIRrVEgfvOhtDXj/current-state)**
>
> H2O.ai AutoML (wrapped with Python) in KNIME for classification problems - a powerful auto-machine-learning framework (https://hub.knime.com/mlauber71/spaces/P…

> [@Decision tree learner seems to be overfitting](https://forum.knime.com/t/decision-tree-learner-seems-to-be-overfitting/38612/21):
>
> @akhtarameen you can import H2O.ai MOJO models into KNIME, R, Python and Spark (and back). That is why I like to use this format - for example I can develop a model on an R machine and then deploy it on a big data cluster. [This collection](https://kni.me/w/C__oI-oLpF-rrq1J) actually contains Jupiter notebook that basically does the same thing. So you might want to try that. There you might also see how to use relative paths in a notebook. This might be because of different splits in test and training, data prepar…

Then you might be able to try and use [knime weka](https://kni.me/w/eD7J0NznPG9RhM-4) models [in python](https://waikato.github.io/weka-wiki/faqs/can_i_use_weka_from_python/), although I have never done that.

---

<div class="post-metadata">

**Author:** ![TE499OP](https://forum-cdn.knime.com/user_avatar/forum.knime.com/te499op/32/37303_2.png) [@TE499OP](https://forum.knime.com/u/TE499OP)\
**Post date:** [March 4, 2022, 10:42pm UTC](https://forum.knime.com/t/export-knime-ml-to-python-pickle/40419/3 "2022-03-04T22:42:15Z")

</div>

I created the ML model using a Knime Random Forest node. Would I need to build a new knime workflow using a Knime Python node? If so, is there any way to import the Random Forest settings from my original workflow?

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [March 4, 2022, 10:53pm UTC](https://forum.knime.com/t/export-knime-ml-to-python-pickle/40419/4 "2022-03-04T22:53:22Z")

</div>

> [@TE499OP](#):
>
> is there any way to import the Random Forest settings from my original workflow?

I don’t think there is. You will have to find a format that can be used in Python. You can use knime python nodes to just run your favourite python ML library and use knime as an interface - or you can build models in knime that support pmml, mojo or maybe weka formats.

There might also be some specialised deep learning formats (think [ONNX](https://hub.knime.com/knime/extensions/org.knime.features.dl.onnx/latest)) that might be interchangeable between knime and python.

If you just want random forest I would suggest the [H2O implementation](https://kni.me/w/SSefBbXvBELOuj8y).

---

<div class="post-metadata">

**Author:** ![TE499OP](https://forum-cdn.knime.com/user_avatar/forum.knime.com/te499op/32/37303_2.png) [@TE499OP](https://forum.knime.com/u/TE499OP)\
**Post date:** [March 7, 2022, 8:38pm UTC](https://forum.knime.com/t/export-knime-ml-to-python-pickle/40419/5 "2022-03-07T20:38:17Z")

</div>

I appreciate your help.

My goal is to create a regression model and pickle file. I have the data set from my original knime workflow. Using the original data set, I am trying to create a new model, using either pmml, mojo or maybe weka formats. I tried to use the H2O implementation, but I cannot find a way to connect my SQL data source to H2O.

Any ideas?

Thanks,

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [March 7, 2022, 9:19pm UTC](https://forum.knime.com/t/export-knime-ml-to-python-pickle/40419/6 "2022-03-07T21:19:54Z")

</div>

> [@TE499OP](#):
>
> connect my SQL data source to H2O.

You can [download your data into knime](https://kni.me/w/Ke-h87vETvtwqMaW) and then do the model building there or you might use a system like cloudera big data cluster that would support [sparkling water environment from H2O](https://kni.me/e/6dxT_w23ASxJUye9) which is supported by knime.

> **[Combine Big Data, Spark and H2O.ai Sparkling Water – mlauber71](https://hub.knime.com/mlauber71/spaces/Public/kn_example_h2o_sparkling_water~SSefBbXvBELOuj8y/current-state)**
>
> \- load data into (local) Big Data environment - load data into Spark context - load data into H2O.ai Sparkling Water context - build H2O model in Big Data envi…

---

<div class="post-metadata">

**Author:** ![SamirAbida](https://forum-cdn.knime.com/user_avatar/forum.knime.com/samirabida/32/28904_2.png) [@SamirAbida](https://forum.knime.com/u/SamirAbida)\
**Post date:** [March 8, 2022, 6:34am UTC](https://forum.knime.com/t/export-knime-ml-to-python-pickle/40419/7 "2022-03-08T06:34:34Z")

</div>

@mlauber71,

off-topic, and out of curiosity, could you please tell me why you’ll prefer to use H2O RF over python or Knime basic node ?

Many thanks.  
Regards,  
Samir

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [March 8, 2022, 10:42am UTC](https://forum.knime.com/t/export-knime-ml-to-python-pickle/40419/8 "2022-03-08T10:42:11Z")

</div>

> [@SamirAbida](#):
>
> why you’ll prefer to use H2O RF over python or Knime basic node

The use of H2O (especially the [automl functions](https://forum.knime.com/t/h2o-ai-automl-in-knime-for-classification-problems/20923)) with R/RStudio or Python (or encapsulated in a KNIME node) would give you more output like

- details about the choosen model
- variable importance
- advanced configuration settings thru code
- you could use hyper parameter grid search for GBM or other model types in code

The good news is: all options do work with KNIME and thanks to the MOJO format you can interchange the results between KNIME, R&Python and BIgData.

---

<div class="post-metadata">

**Author:** ![SamirAbida](https://forum-cdn.knime.com/user_avatar/forum.knime.com/samirabida/32/28904_2.png) [@SamirAbida](https://forum.knime.com/u/SamirAbida)\
**Post date:** [March 8, 2022, 1:33pm UTC](https://forum.knime.com/t/export-knime-ml-to-python-pickle/40419/9 "2022-03-08T13:33:32Z")

</div>

Many thanks @mlauber71,

Thank you for your guidance.

Regards
