use of org.knime.core.node.ModelContentWO in project knime-core by knime.
the class BasisFunctionFactory method save.
/**
* Saves to model content.
* @param pp the model content this is saved to.
*/
public void save(final ModelContent pp) {
pp.addInt(CFG_DISTANCE, m_distance);
ModelContentWO modelSpec = pp.addModelContent(CFG_MODEL_SPEC);
m_spec.save(modelSpec);
}
use of org.knime.core.node.ModelContentWO in project knime-core by knime.
the class FuzzyBasisFunctionPredictorRow method save.
/**
* {@inheritDoc}
*/
@Override
public void save(final ModelContentWO pp) {
super.save(pp);
pp.addInt(Norm.NORM_KEY, m_norm);
ModelContentWO memParams = pp.addModelContent("membership_functions");
for (int i = 0; i < m_mem.length; i++) {
m_mem[i].save(memParams.addModelContent("" + i));
}
}
use of org.knime.core.node.ModelContentWO in project knime-core by knime.
the class CAIMDiscretizationNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
ModelContent binModel = new ModelContent(SAVE_INTERNALS_FILE_NAME);
// save the table spec of included names first
ModelContentWO sub = binModel.addModelContent(CONFIG_KEY_COLUMN_NANES);
DataTableSpec spec = (DataTableSpec) m_discretizationModel.getSpec();
spec.save(sub);
// now save the model.
m_discretizationModel.saveToModelContent(binModel);
File internalsFile = new File(nodeInternDir, SAVE_INTERNALS_FILE_NAME);
BufferedOutputStream out = new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(internalsFile)));
binModel.saveToXML(out);
}
use of org.knime.core.node.ModelContentWO in project knime-core by knime.
the class AffineTransConfiguration method save.
/**
* Saves this object to the argument model content.
* @param model To write to.
*/
protected void save(final ModelContentWO model) {
ModelContentWO colSub = model.addModelContent(CFG_COLUMNS);
for (int i = 0; i < m_includeNames.length; i++) {
String name = m_includeNames[i];
double scale = m_scales[i];
double transl = m_translations[i];
double min = m_min[i];
double max = m_max[i];
if (name == null) {
assert Double.isNaN(scale) && Double.isNaN(transl);
continue;
}
ModelContentWO sub = colSub.addModelContent(name);
sub.addString(CFG_NAME, name);
sub.addDouble(CFG_SCALE, scale);
sub.addDouble(CFG_TRANSLATE, transl);
sub.addDouble(CFG_MIN, min);
sub.addDouble(CFG_MAX, max);
}
model.addString(CFG_SUMMARY, m_summary);
}
use of org.knime.core.node.ModelContentWO in project knime-core by knime.
the class MultiLayerPerceptron method savePredictorParams.
/**
* Stores this MLP model to config.
*
* @param predParams ModelContent to write into.
*/
public void savePredictorParams(final ModelContentWO predParams) {
predParams.addInt(MODE_KEY, m_mode);
ModelContentWO layers = predParams.addModelContent(ALLLAYERS_KEY);
for (int l = 0; l < m_layers.length; l++) {
Layer mylayer = m_layers[l];
Perceptron[] neurons = mylayer.getPerceptrons();
ModelContentWO layerconf = layers.addModelContent("" + l);
if (l == 0) {
// Input Layer must be handled seperately.
for (int n = 0; n < neurons.length; n++) {
ModelContentWO neuronsconf = layerconf.addModelContent("" + n);
neuronsconf.addDouble(INPUT_KEY, ((InputPerceptron) neurons[n]).getInput());
neuronsconf.addString(CLASSVALUE_KEY, neurons[n].getClassValue());
}
} else {
for (int n = 0; n < neurons.length; n++) {
ModelContentWO neuronsconf = layerconf.addModelContent("" + n);
neuronsconf.addDoubleArray(WEIGHT_KEY, neurons[n].getWeights());
neuronsconf.addDouble(THRESHOLD_KEY, neurons[n].getThreshold());
if (neurons[n].getClassValue() != null) {
neuronsconf.addString(CLASSVALUE_KEY, neurons[n].getClassValue());
}
}
}
}
}
Aggregations