I need to save the classification models from various classifiers. Weka Classifier Writer (3.6) works only for Weka package classifiers. How can I solve this for classifiers located in Mining section?
Also, I am working in a loop so how can I save the models for each iteration without overwriting?
If the classifier can output a PMML model then you can use the PMML writer:
"Writes a model from a PMML model port into a PMML v4.0 compliant file. Select a file to write to. If the file already exist it is silently overwritten! Be sure to have write access to the entered file. If a PMML file from another version is read by the PMML Reader and directly written by this node, it is converted into PMML v4.0. If the model is not valid (unknown data types, etc.) an exception is thrown during execution."
To write them out in a loop you will need to configure the writers output file with a flow variable. You could for example build a string like
myFlowVar = "c:\myFolder\" + iteration + ".pmml";
Then use myFlowVar to control the save location. You can probably do this with a String manipulation node. You definately can with a Java snippet.
Thank you Sam,
I used PMML Writer as you suggested and Java Edit Variable (Simple).
Now the problem is during the loop, iteration is not updated for this issue and I can only write the first model. Then the PMML Writer gives error "File exists and can't be overwritten"
How can I solve this?
I suspect you are not updating the filename in the loop properly. I have attached a workflow that builds 10 models on the iris data and saves them to a specified workflow. Look at the Java Edit Variable for how the variable for the filename is created.
Explanation of the Java snippet:
// Create the new filename
out_iterationSaveLocation = v_saveLocation + "model-" + v_currentIteration + ".pmml";
At the start of the workflow I created a saveLocation variable containing the folder location I want to use for saving my files. In the snippet I create a new variable 'iterationSaveLocation' and create this using String concatenation of the saveLocation variable and the vlaues "model-" the current iteration of the loop (this makes it unique) and finally ".pmml".
So I end up with something like:
Where v_saveLocation is: C:\container\testSaveWorkflowOutput\
and v_CurrentIteration is 0.
Hope the workflow helps.