use of org.knime.core.node.config.Config in project knime-core by knime.
the class PMMLCompoundPredicate method saveToPredParams.
/**
* {@inheritDoc}
*/
@Override
public void saveToPredParams(final Config conf) {
conf.addString(PMMLPredicate.TYPE_KEY, NAME);
conf.addString(PMMLPredicate.OPERATOR_KEY, m_op.toString());
String splitAttribute = getSplitAttribute();
conf.addString(PMMLPredicate.ATTRIBUTE_KEY, splitAttribute);
conf.addInt(NUM_PREDICATES, m_predicates.size());
int i = 0;
for (PMMLPredicate pred : m_predicates) {
Config pconf = conf.addConfig(PRED + i++);
pred.saveToPredParams(pconf);
}
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class DecisionTreeNode method saveToPredictorParams.
// ////////////////////////////////////
// Save & Load to/from ModelContent
// ////////////////////////////////////
/**
* Save node to a model content object.
*
* @param predParams configuration object to attach decision tree to
* @param saveColorsAndKeys whether to save the colors and the row keys
*/
public void saveToPredictorParams(final ModelContentWO predParams, final boolean saveColorsAndKeys) {
predParams.addDataCell("class", m_class);
predParams.addDouble("allClassFreq", m_allClassFreq);
predParams.addDouble("ownClassFreq", m_ownClassFreq);
predParams.addInt("ownIndex", m_ownIndex);
predParams.addString("prefix", m_prefix);
predParams.addBoolean("newColors", m_newColors);
// also write out frequencies of all classes
DataCell[] keys = new DataCell[m_classCounts.size()];
double[] values = new double[m_classCounts.size()];
int i = 0;
for (Entry<DataCell, Double> mapIt : m_classCounts.entrySet()) {
keys[i] = mapIt.getKey();
values[i] = mapIt.getValue();
i++;
}
predParams.addDataCellArray("classes", keys);
predParams.addDoubleArray("frequencies", values);
// need to re-create when loading this node...
if (this instanceof DecisionTreeNodeLeaf) {
predParams.addString("className", "LeafNode");
} else if (this instanceof DecisionTreeNodeSplitContinuous) {
predParams.addString("className", "ContinuousSplit");
} else if (this instanceof DecisionTreeNodeSplitNominal) {
predParams.addString("className", "NominalSplit");
} else if (this instanceof DecisionTreeNodeSplitPMML) {
predParams.addString("className", "PMMLPredicateSplit");
} else {
LOGGER.error("DecisionTreeNode.saveToPredictorParams() doesn't" + " know this node type: " + this.getClass().getName());
}
// and finally save all internals of the derived class as well
saveNodeInternalsToPredParams(predParams, saveColorsAndKeys);
// if the keys and colors are supposed to be stored
if (saveColorsAndKeys) {
Config colorsConfig = predParams.addConfig(CONFIG_KEY_COLORS);
int counter = 0;
for (Entry<Color, Double> entry : m_coveredColors.entrySet()) {
Config colorConfig = colorsConfig.addConfig(CONFIG_KEY_COLOR + "_" + counter);
colorConfig.addInt(CONFIG_KEY_RED, entry.getKey().getRed());
colorConfig.addInt(CONFIG_KEY_GREEN, entry.getKey().getGreen());
colorConfig.addInt(CONFIG_KEY_BLUE, entry.getKey().getBlue());
colorConfig.addDouble(CONFIG_KEY_COUNT, entry.getValue());
counter++;
}
}
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class DiscretizationModel method save.
/**
* {@inheritDoc}
* <p />
* IMPORTANT NOTE: This method DOES NOT save the table spec of included
* columns. This table spec must be saved before (by calling getSpec and
* saving the returned object).
*/
@Override
protected void save(final ModelContentWO model, final ExecutionMonitor exec) throws CanceledExecutionException {
Config schemesConfig = model.addConfig(CONFIG_KEY_SCHEMES);
int i = 0;
for (DiscretizationScheme scheme : m_schemes) {
if (exec != null) {
exec.checkCanceled();
}
Config schemeConfig = schemesConfig.addConfig(CONFIG_KEY_SCHEME_PREFIX + m_includedColumnNames.getColumnSpec(i).getName());
scheme.saveToModelContent(schemeConfig);
i++;
}
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class DiscretizationScheme method saveToModelContent.
/**
* Saves this scheme to a {@link org.knime.core.node.ModelContentWO} object.
*
* @param modelContent the {@link Config} object to store the
* {@link DiscretizationScheme} to
*/
public void saveToModelContent(final Config modelContent) {
int i = 0;
for (Interval interval : m_intervals) {
Config intervalConfig = modelContent.addConfig(CONFIG_KEY_INTERVAL_PREFIX + i);
interval.saveToModelContent(intervalConfig);
i++;
}
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class AggregationValModel method save2File.
/**
* @param config the config object to use
* @param exec the {@link ExecutionMonitor} to provide progress messages
* @throws CanceledExecutionException if the operation is canceled
*/
public void save2File(final ConfigWO config, final ExecutionMonitor exec) throws CanceledExecutionException {
config.addString(CFG_BAR_NAME, getName());
config.addInt(CFG_COLOR_RGB, getColor().getRGB());
config.addInt(CFG_ROW_COUNTER, getRowCount());
config.addInt(CFG_VALUE_COUNTER, getValueCount());
config.addDouble(CFG_AGGR_SUM, getAggregationSum());
config.addBoolean(CFG_HILITING, supportsHiliting());
final Config subConfig = config.addConfig(CFG_SUBMODELS);
saveElements(getElements(), subConfig, exec);
}
Aggregations