# Exporting learning model results from analysis nodes

**URL:** <https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793>\
**Category:** KNIME Analytics Platform\
**Tags:** python, big-data\
**Created:** [December 6, 2023, 4:48am UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793 "2023-12-06T04:48:02Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![JaeHwanChoi](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JaeHwanChoi](https://forum.knime.com/u/JaeHwanChoi)\
**Post date:** [December 6, 2023, 4:48am UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/1 "2023-12-06T04:48:02Z")

</div>

Hello KNIME Support team.

In Python, you can export the trained model via PKL file during machine learning, but in KNIME, when using the Analyze node, you can export the model information to the blue or gray port.

However, some models can only be exported to PMML Writer and some models can only be exported to Model Writer. Is there a common node that can be exported?

![image](https://forum-cdn.knime.com/uploads/default/original/3X/d/1/d17d8646c0040bd69c49636a73bc08fb71dd8ba3.png)

Additionally, I want to export the model trained with ML node to PMML & Model Writer, and then import the file into my personal jupyter notebook to use it for prediction, can I use the model created in KNIME only in KNIME?

I would be grateful for your reply.

---

<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:** [December 6, 2023, 5:20am UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/2 "2023-12-06T05:20:07Z")

</div>

@JaeHwanChoi pmml should be standard and be able to use in other systems. Though it seems to have some [limitations](https://forum.knime.com/t/when-to-use-pmml-model-appender-and-pmml-transformation-appender/44890/7)

> [@Export PMML that outputs class probabilities](https://forum.knime.com/t/export-pmml-that-outputs-class-probabilities/13244/2):
>
> I think it depends on the type of model. Normally you would have to tell the Predictor to add the class probabilities. The generic PMML predictor does not have this function - or it depends on the type of model. Nodes that support Probabilities and PMML are: Additionally the Decision Tree offers the possibility to create a quite readably [ruleset](https://nodepit.com/node/org.knime.base.node.rules.engine.decisiontree.FromDecisionTreeNodeFactory) that you can then use with SQL or another language Additionally the Supports these model types and also has the possibility to…

A lengthy discussion about the exchange of models between knime and python can be found here:

> [@Error when importing KNIME's Model file in Jupyter](https://forum.knime.com/t/error-when-importing-knimes-model-file-in-jupyter/70699/4):
>
> @JaeHwanChoi the model writer will zip a given model to store it. Underneath there has to be a model that the package that you used can read([KNIME ML to Python - #2 by mlauber71](https://forum.knime.com/t/knime-ml-to-python/44220/2) ). If you want to use it with Jupyter notebooks this has to work in both environments. You could try and store a model just as pickel and use knime as interface for some python models. Here are examples from several versions of knime and python: There are other frameworks you could use. Knime started to generic…

From my experience the best model format to interchange between knime, python, R and even [Spark/BigData](https://hub.knime.com/-/spaces/-/~SSefBbXvBELOuj8y/current-state/) systems is H2O.ai MOJO:

> **[use KNIME / Python and LightGBM to build a model - Hyperparameter tuning with...](https://hub.knime.com/mlauber71/spaces/Machine_Learning/ml_binary/kn_example_ml_binary_lightgbm_hyper_parameter_opt~GABT_OgeoWxWJW9P/current-state)**
>
> use KNIME / Python and LightGBM to build a model - Hyperparameter tuning with BayesSearchCV and Optuna - also preparing data with vtreat some parameters have b…

KNIME has started to support Sklearn nodes. Though I have not tried to interchange their models with python (via pickle for example):

> **[Sklearn: The KNIME Nodes for Scikit-Learn (sklearn) Algorithms - used to...](https://hub.knime.com/mlauber71/spaces/Machine_Learning/ml_regression/kn_example_ml_regression_sklearn~BWu3F88pMlHHuJiB/current-state)**
>
> Sklearn: The KNIME Nodes for Scikit-Learn (sklearn) Algorithms - used to predict housing prices

This seem to be the only change since we last had this discussion. The format of a model very much depends on the underlying system and packages. KNIME as a platform is trying to bring them together but I don’t think there is a universal solution or a format to cover everything. For deep learning there is [ONNX](https://hub.knime.com/knime/extensions/org.knime.features.dl.onnx/latest/org.knime.dl.onnx.base.nodes.reader.ONNXReaderNodeFactory/) but my experience here is limited.

---

<div class="post-metadata">

**Author:** ![Daniel\_Weikert](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@Daniel\_Weikert](https://forum.knime.com/u/Daniel_Weikert)\
**Post date:** [December 6, 2023, 4:45pm UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/3 "2023-12-06T16:45:00Z")

</div>

@mlauber71  
Did you experience any specific benefits of using an ML Model in KNIME rather then using python directly? Just curious

---

<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:** [December 6, 2023, 5:57pm UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/4 "2023-12-06T17:57:31Z")

</div>

@Daniel_Weikert well there is the low-code thing. KNIME nodes can help you with the configurations. Also KNIME can be your platform to integrate several aspects and approaches and then compare them.

---

<div class="post-metadata">

**Author:** ![JaeHwanChoi](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JaeHwanChoi](https://forum.knime.com/u/JaeHwanChoi)\
**Post date:** [December 7, 2023, 5:34am UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/5 "2023-12-07T05:34:06Z")

</div>

Thank you for your response. @mlauber71 !!

Does this mean that the files exported by PMML Writer can be used standardly in other systems (R, Python), and the files exported by Model Writer cannot be used standardly because it is a KNIME-specific extension?

Also, some models can only be exported to PMML Writer and some models can be exported to Model Writer, but why is this distinction made?

Any answers would be greatly appreciated.

---

<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:** [December 7, 2023, 6:59am UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/6 "2023-12-07T06:59:48Z")

</div>

@JaeHwanChoi the format and interoperability very much depends on the issuer of such model systems. PMML is supposed to be some sort of standard for a group of models though I found it might not always work on all platforms and does not cover some advanced models like XGBoost.

There is no such thing as a universal model format, especially not one that would work on all environments per operating systems. It will always depend on the environment used. KNIME is a platform to them and makes the use easier.

As I said. My best experience with interoperability is with H2O.ai MOJO format - you can use them seamlessly with KNIME, R and Python.

In this collection you will find several examples of interaction between knime and namely Python.

> **[mlauber71/Machine\_Learning – ml\_binary](https://hub.knime.com/mlauber71/spaces/Machine_Learning/ml_binary~ch4Uag7CQUG1v2F1/)**
>
> contains 4 items

---

<div class="post-metadata">

**Author:** ![JaeHwanChoi](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JaeHwanChoi](https://forum.knime.com/u/JaeHwanChoi)\
**Post date:** [December 12, 2023, 1:36pm UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/7 "2023-12-12T13:36:36Z")

</div>

Thank you for your response. @mlauber71

To send and receive models interoperably with R and Python, KNIME uses the h2o node to convert the trained model to “H2O Model to MOJO” and export it to “H2O MOJO Writer” and read the model using h2o-related code in Python?

I’m asking because I saw a related example WF, but it doesn’t have the process I want.

---

<div class="post-metadata">

**Author:** ![JaeHwanChoi](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JaeHwanChoi](https://forum.knime.com/u/JaeHwanChoi)\
**Post date:** [December 12, 2023, 1:59pm UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/8 "2023-12-12T13:59:48Z")

</div>

Even though I exported the model from KNIME to mojo, I can’t seem to access h2o on my personal PC, a Jupyter notebook, unless I have h2o installed. I have installed the package, but do I need to have the actual paid or demo version of h2o to use the h2o model in Jupyter?

---

<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:** [December 12, 2023, 3:15pm UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/9 "2023-12-12T15:15:49Z")

</div>

@JaeHwanChoi you can use the free version. You will have to have the h2o package installed and need to start a h2o process in the background.

Here is a notebook (I am planning to write a blog about it):

> <https://github.com/ml-score/knime_meets_python/blob/main/machine_learning/binary/notebooks/kn_example_python_h2o_automl.ipynb>

You can import a mojo model from knime at any point. Or you can import a model you created in a jupyter notebook into knime. Or you just use the Python node to run model created in Python in knime and read the results.

> **[use KNIME / Python and LightGBM to build a model - Hyperparameter tuning with...](https://hub.knime.com/mlauber71/spaces/Machine_Learning/ml_binary/kn_example_ml_binary_lightgbm_hyper_parameter_opt~GABT_OgeoWxWJW9P/current-state)**
>
> use KNIME / Python and LightGBM to build a model - Hyperparameter tuning with BayesSearchCV and Optuna - also preparing data with vtreat some parameters have b…

If you want sample code in R there is an example in this workflow group

> **[mlauber71/Public – script](https://hub.knime.com/mlauber71/spaces/Public/kn_example_bigdata_h2o_automl_spark_46/script~QUmS0UpjIpBKqIFT/)**
>
> contains 3 items

---

<div class="post-metadata">

**Author:** ![Daniel\_Weikert](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@Daniel\_Weikert](https://forum.knime.com/u/Daniel_Weikert)\
**Post date:** [December 12, 2023, 5:39pm UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/10 "2023-12-12T17:39:43Z")

</div>

@JaeHwanChoi  
What exactly is the usecase for exporting models from KNIME? Why not making predictions in KNIME directly?  
Just curious.

---

<div class="post-metadata">

**Author:** ![JaeHwanChoi](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JaeHwanChoi](https://forum.knime.com/u/JaeHwanChoi)\
**Post date:** [December 13, 2023, 1:17am UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/11 "2023-12-13T01:17:28Z")

</div>

Thanks @mlauber71

If I need to start the h2o process in the background, does that mean I need to get and run a free demo of h20 so I can run h2o-related Python code in Jupyter on my local PC?

In other words, what I want to do is to turn the model generated by h2o automl in KNIME into a mojo, export it to mojo writer, and then import the exported mojo via h2o package in my personal Jupyter for forecasting.

The current problem is that I exported the model from KNIME, but when I install the h2o package in my personal Jupyter, I get a code error in the h2o.init() code because I don’t have a free version of the actual h2o available.

Please help.

---

<div class="post-metadata">

**Author:** ![JaeHwanChoi](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JaeHwanChoi](https://forum.knime.com/u/JaeHwanChoi)\
**Post date:** [December 13, 2023, 1:26am UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/12 "2023-12-13T01:26:22Z")

</div>

A typical partner project wants to deploy KNIME-generated models to a specific storage, and then import those models into their own Python for forecasting, which means there is a constant demand for model compatibility between KNIME and Python.

To summarize based on the discussion so far, the only model that is compatible between KNIME and Python is h2o mojo, and models exported with “model writer” cannot use extensions that are only applicable in KNIME. In addition, the models that provide pmml are limited.

So, if you exported to h2o mojo, you need to subscribe to the actual h2o commercial version or demo version to use it in your personal jupyter to run h2o-related code.

Please confirm if the above summary is correct. @mlauber71!!

---

<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:** [December 13, 2023, 5:15am UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/13 "2023-12-13T05:15:52Z")

</div>

> [@JaeHwanChoi](#):
>
> I get a code error in the h2o.init() code because I don’t have a free version of the actual h2o available.

I would suggest to install the h2o python package so you have access to it. This will be a complete working package not a demo.

> conda install -c h2oai h2o

> **[KNIME and Python — Setting up and managing Conda environments](https://medium.com/low-code-for-advanced-data-science/knime-and-python-setting-up-and-managing-conda-environments-2ac217792539)**
>
> TL;DR: install python/conda thru Miniforge, find and use specific YAML-files to manage an environment, tell KNIME and use their…

What kind of error message do you get? In the notebook there is an explanation how to use knime’s on board Java engine (which h2o will need) if you do not have a current version on your machine (see the end of this article: [KNIME Snippets (2): Unearthing Hidden Node Gems — Managing Missing Values, Row Numbers and some Quick Java and Paths | by Markus Lauber | Low Code for Data Science | Medium](https://medium.com/p/3c3c7acb019f)).

The sample workflow above shows the interaction between knime and several python based modeling packages including [XGBoost](https://medium.com/@mlxl/knime-xgboost-and-optuna-for-hyper-parameter-optimization-dcf0efdc8ddf) and [Lightgbm](https://medium.com/low-code-for-advanced-data-science/hyperparameter-optimization-for-lightgbm-wrapped-in-knime-nodes-ddb7ae1d7e2). I assume setting this up and working with it will give you additional insights.

 ![IMG_6180](https://forum-cdn.knime.com/uploads/default/original/3X/f/2/f2b49c26988634cfa94965e8707eaf0d75414c24.jpeg)

> **[use KNIME / Python and LightGBM to build a model - Hyperparameter tuning with...](https://hub.knime.com/mlauber71/spaces/Machine_Learning/ml_binary/kn_example_ml_binary_lightgbm_hyper_parameter_opt~GABT_OgeoWxWJW9P/current-state)**
>
> use KNIME / Python and LightGBM to build a model - Hyperparameter tuning with BayesSearchCV and Optuna - also preparing data with vtreat some parameters have b…

If you want to avoid the hassel of installing and managing python packages and dependencies you could just use KNIME. Although KNIME can also help with that task.

---

<div class="post-metadata">

**Author:** ![JaeHwanChoi](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JaeHwanChoi](https://forum.knime.com/u/JaeHwanChoi)\
**Post date:** [December 13, 2023, 6:05am UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/14 "2023-12-13T06:05:07Z")

</div>

When you install and run Konda, you’ll see a message like the one below. It says I can’t access the server, but don’t I need a license of commercial h2o (like the demo version) to access the h2o server after all?

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/5/e/5ed50155107a03117f19788dacad576179d23f56.png)

Installing Java, which is OpenJDK, doesn’t seem to solve it.

---

<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:** [December 13, 2023, 6:18am UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/15 "2023-12-13T06:18:44Z")

</div>

@JaeHwanChoi I cannot read the whole error message. You will not need a license to use the free h2o version. You could try and use knime’s internal Java engine as said before.

Also you might plan ahead what you want to do in which system. Now you are trying to run h2o within a python node in knime which is also possible.

> **[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…

> [@H2O.ai AutoML in KNIME for classification problems](https://forum.knime.com/t/h2o-ai-automl-in-knime-for-classification-problems/20923):
>
> H2O.ai Automl - a powerful auto-machine-learning framework wrapped with KNIME It features various models like Random Forest or XGBoost along with Deep Learning. It has wrappers for R and Python but also could be used from KNIME. The results will be written to a folder and the models will be stored in MOJO format to be used in KNIME (as well as on a Big Data cluster via Sparkling Water). One major parameter to set is the running time the model has to test various models and do some hyperparam…

Using knime, python and h2o (with Java under the hood) will require to find the right setup.

* * *

Just to make sure: knime also [does support the commercial product h2o driverless AI](https://www.knime.com/partners/h2o-partnership). This uses different model formats which are not compatible with the open version and indeed will need a license and also a powerful server.

[https://docs.knime.com/latest/h2o\_driverless\_ai\_guide/#introduction](https://docs.knime.com/latest/h2o_driverless_ai_guide/#introduction)

---

<div class="post-metadata">

**Author:** ![JaeHwanChoi](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JaeHwanChoi](https://forum.knime.com/u/JaeHwanChoi)\
**Post date:** [December 13, 2023, 10:48am UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/16 "2023-12-13T10:48:57Z")

</div>

Can you tell me what version of Java you’re using?

---

<div class="post-metadata">

**Author:** ![Daniel\_Weikert](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@Daniel\_Weikert](https://forum.knime.com/u/Daniel_Weikert)\
**Post date:** [December 13, 2023, 5:13pm UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/17 "2023-12-13T17:13:06Z")

</div>

“Deploy” as using the KNIME specific deployment nodes? Or “just” deploy as a regular workflow which uses those models on the hub?  
A regular workflow could also use standard python nodes and then there would not be any compatibility issue I assume?

edit: Have tried h2o in python using colab before. It was free as @mlauber71 said.  
br

---

<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:** [December 13, 2023, 8:07pm UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/18 "2023-12-13T20:07:42Z")

</div>

> [@Daniel\_Weikert](#):
>
> A regular workflow could also use standard python nodes and then there would not be any compatibility issue I assume?

With the bundled Python version one can use the sklearn package with the Knime Python nodes. My impression is the first task would be to make a plan what software and system should be used on which environment and also what skill levels will be needed by the people using it.

> **[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_2022~HIFbIx26objNVR40/current-state)**
>
> Simple example to make a random forest model with new Python Scrip in KNIME 4.6 using the iris dataset. Saving and reusing the model with Pickle Also creating …

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [March 12, 2024, 8:07pm UTC](https://forum.knime.com/t/exporting-learning-model-results-from-analysis-nodes/75793/19 "2024-03-12T20:07:59Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
