use of org.knime.base.node.preproc.groupby.GroupKey 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());
}
}
}
use of org.knime.base.node.preproc.groupby.GroupKey in project knime-core by knime.
the class NumericOutliersModel method loadModel.
/**
* Loads the information provided by the model content into the model.
*
* @param model the model content to be loaded
* @throws InvalidSettingsException if the outliers defined by the model content differs from the outliers defining
* the intervals
*/
@SuppressWarnings("unchecked")
private void loadModel(final ModelContentRO model) throws InvalidSettingsException {
final Enumeration<ModelContentRO> rowContents = model.children();
while (rowContents.hasMoreElements()) {
// acess the current group
final ModelContentRO rowContent = rowContents.nextElement();
// load the group key
final GroupKey key = new GroupKey(rowContent.getModelContent("key").getDataCellArray(CFG_GROUP_KEY));
// load all intervals for the current group key
ModelContentRO intervalCols = rowContent.getModelContent(CFG_INTERVAL_COLUMNS);
final Enumeration<ModelContentRO> intervalContents = intervalCols.children();
while (intervalContents.hasMoreElements()) {
final ModelContentRO intervalContent = intervalContents.nextElement();
addEntry(key, intervalContent.getString("outlier"), intervalContent.getDoubleArray(CFG_INTERVAL));
}
}
}
Aggregations