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 + ")");
}
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());
}
}
}
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());
}
}
}
Aggregations