KNIME ML to Python

Dear KNIME-community

I created different machine learning models in KNIME. Now I want to export the model so I can use it in Python for the business. I’ve seen a few discussions about the other way round and export the model with the “Model Writer”-node. I used it but I’m not sure how to import it in python.

Do you have any idea to solve this problem?

Best :slight_smile:

@BrBr two options would be to use H2O.ai models or PMML

@mlauber71 thank you for your answer!
Do I need specific nodes to write it with H2O? I used the “classic” nodes and no specific ones.

I created a good working Random Forest Classification Model and want to run it in python language. In the nodes I have in KNIME there’re some nodes for Gradient Boosted Trees or Simple regression trees. Maybe I’m just blind or need to download the right nodes…

@BrBr you can use H2O models in KNIME and python and load them in both systems. A basic H2O workflow could look like this:

Maybe you also check this example and article. In the subfolder /script/ there is a jupyter notebook that shows the use in python also to import H2O MOJO model files.

2 Likes

I’ve read all the examples from you but for me it’s not really clear how to use it on my data and with my specific model. I’m a chemist and wanted to improve our workflow. So for me it’s not really clear if and how I can use the trained model for the classification.
Your created workflows are amazing and I think you invested a lot of time in it! Impressive! But maybe I’m to blind to see where the mode is saved to extract it to another platform. Can you tell me please?
And maybe another question. At the moment I have a good model and I want to run it with new unknown samples. Is it also possible to improve constantly the model with the new data?
Thank you very much for your help and sorry for those questions.

If you export using pmml writer you should be able to import the file in python e.g. with

br

2 Likes

I can try and make a more focused example of how to interact with models between KNIME and python.

The model gets saved as a MOJO file right there in my first example. This zip file can later be used in KNIME or in another system that supports H2O like Python or R. And it works the other way round also.

Another option would be PMML for models which do support that. Issues here can be to have the right version and not all PMML models support probabilities which I often need.

2 Likes

Hi @mlauber71
I could write it and now I want to test in in Python. Thank you for your help! After a closer look it was totally clear, maybe I spent to much time with KNIME and all the nodes and lost the overview :smiley:

2 Likes