Search in sources :

Example 21 with ModelContentWO

use of org.knime.core.node.ModelContentWO in project knime-core by knime.

the class OneMissingValueReplacementFunction method saveInfos.

/**
 * Saves the results of the training to the given object as string key-value
 * pairs.
 *
 * @param pp the object to write result strings to
 */
public void saveInfos(final ModelContentWO pp) {
    pp.addString("Number of epochs: ", "" + m_cycles);
    pp.addString("Number of classes: ", "" + m_bfs.keySet().size());
    pp.addString("Number of rules learned per class: ", "(in total " + getNumBasisFunctions() + ")");
    ModelContentWO classContent = pp.addModelContent("class_info");
    for (DataCell classInfo : m_bfs.keySet()) {
        classContent.addString(classInfo.toString() + ": ", "" + getNumBasisFunctions(classInfo));
    }
    pp.addString("Number of training instances per class: ", "(in total)");
    ModelContentWO statisticsContent = pp.addModelContent("learner_info");
    int cnt = 0;
    for (DataCell classLabel : m_numPatPerClass.keySet()) {
        int value = m_numPatPerClass.get(classLabel)[0];
        statisticsContent.addString("\t" + classLabel + ": ", "" + value);
        cnt += value;
    }
    pp.addString("Number of training instances per class: ", "(in total " + cnt + ")");
}
Also used : ModelContentWO(org.knime.core.node.ModelContentWO) DataCell(org.knime.core.data.DataCell)

Example 22 with ModelContentWO

use of org.knime.core.node.ModelContentWO in project knime-core by knime.

the class MemberCounter method saveModel.

/**
 * Saves the member counter to the provided model content.
 *
 * @param model the model content to save to
 */
void saveModel(final ModelContentWO model) {
    int gInd = 0;
    for (Entry<String, Map<GroupKey, Integer>> entry : m_groupCounts.entrySet()) {
        final ModelContentWO colSettings = model.addModelContent(CFG_OUT_COL + gInd++);
        colSettings.addString(CFG_OUT_COL_NAME, entry.getKey());
        final ModelContentWO groupCounts = colSettings.addModelContent(CFG_GROUP_COUNTS);
        int oInd = 0;
        for (Entry<GroupKey, Integer> gCountEntry : entry.getValue().entrySet()) {
            final ModelContentWO groupCount = groupCounts.addModelContent(CFG_GROUP_COUNT + oInd++);
            groupCount.addDataCellArray(CFG_GROUP_KEY, gCountEntry.getKey().getGroupVals());
            groupCount.addInt(CFG_GROUP_VAL, gCountEntry.getValue());
        }
    }
}
Also used : ModelContentWO(org.knime.core.node.ModelContentWO) GroupKey(org.knime.base.node.preproc.groupby.GroupKey) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 23 with ModelContentWO

use of org.knime.core.node.ModelContentWO in project knime-core by knime.

the class NumericOutliersModel method saveModel.

/**
 * Save the model to the provided model content.
 *
 * @param model the model to save to
 */
void saveModel(final ModelContentWO model) {
    // store groups and outlier column names
    model.addStringArray(CFG_GROUP_COL_NAMES, m_groupColNames);
    model.addStringArray(CFG_OUTLIER_COL_NAMES, m_outlierColNames);
    // store the permitted intervals for each group and outlier column
    final ModelContentWO data = model.addModelContent(CFG_DATA);
    int rowCount = 0;
    for (Entry<GroupKey, Map<String, double[]>> entry : m_permIntervals.entrySet()) {
        final ModelContentWO rowContent = data.addModelContent(CFG_ROW + rowCount++);
        // store the group key
        rowContent.addModelContent("key").addDataCellArray(CFG_GROUP_KEY, entry.getKey().getGroupVals());
        // store the permitted intervals for the given key
        ModelContentWO intervalCols = rowContent.addModelContent(CFG_INTERVAL_COLUMNS);
        int intervalCount = 0;
        for (Entry<String, double[]> interval : entry.getValue().entrySet()) {
            final ModelContentWO rowIntervalContent = intervalCols.addModelContent(CFG_INTERVAL + intervalCount++);
            rowIntervalContent.addString("outlier", interval.getKey());
            rowIntervalContent.addDoubleArray(CFG_INTERVAL, interval.getValue());
        }
    }
}
Also used : ModelContentWO(org.knime.core.node.ModelContentWO) GroupKey(org.knime.base.node.preproc.groupby.GroupKey) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

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