I need to save a model (e.g. linear regression learner) and then use it in a python script.
At the moment the model is saved with a ‘model writer’ node, but the format of the file ‘modelPolinRegr’ is not usable in a script:
path = os.getcwd() + os.sep + ‘data’ + os.sep + ‘InputData’ + os.sep + ‘modelPolinRegr’
model = pickle.load(open(path, ‘rb’))
Afaik Model writer is knime specific format.
write to a pmml file. That should work
Not all ml model are supported in pmml format.
Have you tried in onnx format?
Not so far,
is there a reason you need to use the KNIME models instead of using python directly?
There is a pmml to cell node. Maybe you could try that and work from there
There is no common format for machine learning models in KNIME AP that can be reused in Python code. The different algorithms usually implement their own format (except for library integrations like TensorFlow, XGBoost, etc.). Therefore, I am afraid that there is no single complete solution to loading any KNIME model in Python.
Using ONNX would be a sound approach. However, currently, there is no converter (that I know of) from any machine learning model in KNIME to ONNX.
If you want to dive deeper into the details, the source of KNIME AP is open. The implementations of the basic ML nodes can be found at GitHub/knime/knime-base.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.