Search in sources :

Example 11 with ModelContentWO

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);
}
Also used : ModelContentWO(org.knime.core.node.ModelContentWO)

Example 12 with ModelContentWO

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));
    }
}
Also used : ModelContentWO(org.knime.core.node.ModelContentWO)

Example 13 with ModelContentWO

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);
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) GZIPOutputStream(java.util.zip.GZIPOutputStream) ModelContent(org.knime.core.node.ModelContent) ModelContentWO(org.knime.core.node.ModelContentWO) FileOutputStream(java.io.FileOutputStream) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 14 with ModelContentWO

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);
}
Also used : ModelContentWO(org.knime.core.node.ModelContentWO)

Example 15 with ModelContentWO

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());
                }
            }
        }
    }
}
Also used : ModelContentWO(org.knime.core.node.ModelContentWO)

Aggregations

ModelContentWO (org.knime.core.node.ModelContentWO)23 BufferedOutputStream (java.io.BufferedOutputStream)7 File (java.io.File)7 FileOutputStream (java.io.FileOutputStream)7 ModelContent (org.knime.core.node.ModelContent)7 GZIPOutputStream (java.util.zip.GZIPOutputStream)6 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 GroupKey (org.knime.base.node.preproc.groupby.GroupKey)2 DataCell (org.knime.core.data.DataCell)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1 ZipEntry (java.util.zip.ZipEntry)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DataTableSpec (org.knime.core.data.DataTableSpec)1 RowKey (org.knime.core.data.RowKey)1 FileStore (org.knime.core.data.filestore.FileStore)1 FileStoreKey (org.knime.core.data.filestore.FileStoreKey)1