use of org.knime.core.node.config.Config in project knime-core by knime.
the class DiscretizationModel method load.
/**
* {@inheritDoc}
* <p />
* IMPORTANT NOTE: This method DOES NOT load the table spec of included
* columns from the provided model. This table spec must be loaded before
* and must be provided here. It is taken over and stored.
*/
@Override
protected void load(final ModelContentRO model, final PortObjectSpec spec, final ExecutionMonitor exec) throws InvalidSettingsException, CanceledExecutionException {
m_includedColumnNames = (DataTableSpec) spec;
try {
Config schemesConfig = model.getConfig(CONFIG_KEY_SCHEMES);
m_schemes = new DiscretizationScheme[schemesConfig.getChildCount()];
int i = 0;
Enumeration<TreeNode> schemeConfigEnum = schemesConfig.children();
while (schemeConfigEnum.hasMoreElements()) {
if (exec != null) {
exec.checkCanceled();
}
Config schemeConfig = (Config) schemeConfigEnum.nextElement();
m_schemes[i] = new DiscretizationScheme(schemeConfig);
i++;
}
} catch (Exception e) {
m_schemes = null;
m_includedColumnNames = null;
}
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class BitVectorAttributeModel method saveModelInternal.
/**
* {@inheritDoc}
*/
@Override
void saveModelInternal(final Config config) {
config.addInt(CLASS_VALUE_COUNTER, m_classValues.size());
int i = 0;
for (final BitVectorClassValue classVal : m_classValues.values()) {
final Config classConfig = config.addConfig(CLASS_VALUE_SECTION + i);
classVal.saveModel(classConfig);
i++;
}
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class NaiveBayesModel method savePredictorParams.
/**
* @param predParams to save the model
*/
public void savePredictorParams(final ConfigWO predParams) {
// Save the classifier column
predParams.addString(CLASS_COL_NAME, m_classColName);
predParams.addBoolean(SKIP_MISSING_VALS, m_skipMissingVals);
// create the skipped attributes section
final Config skippedConfig = predParams.addConfig(SKIPPED_ATTRIBUTE_SECTION);
// save the number of skipped attribute models
skippedConfig.addInt(SKIPPED_ATTRIBUTE_COUNTER, m_skippedAttributes.size());
// save the skipped attribute models
int modelIndex = 0;
for (final AttributeModel model : m_skippedAttributes) {
final Config modelConfig = skippedConfig.addConfig(SKIPPED_ATTRIBUTE_DATA + modelIndex++);
model.saveModel(modelConfig);
}
// create the model config section
final Config modelConfigSect = predParams.addConfig(ATTRIBUTE_MODEL_SECTION);
// Save the total number of records
modelConfigSect.addInt(RECORD_COUNTER, m_noOfRecs);
// save the number of attribute models
modelConfigSect.addInt(ATTRIBUTE_MODEL_COUNTER, m_modelByAttrName.size());
// save the attribute models
modelIndex = 0;
for (final AttributeModel model : m_modelByAttrName.values()) {
final Config modelConfig = modelConfigSect.addConfig(ATTRIBUTE_MODEL_DATA + modelIndex++);
model.saveModel(modelConfig);
}
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class NaiveBayesPortObjectSpec method load.
/**
* {@inheritDoc}
*/
@Override
protected void load(final ModelContentRO model) throws InvalidSettingsException {
final Config specModel = model.getConfig(CNFG_SPEC);
m_tableSpec = DataTableSpec.load(specModel);
final ModelContentRO classColModel = model.getModelContent(CNFG_CLASS_COL);
m_classColumn = DataColumnSpec.load(classColModel);
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class NaiveBayesPortObject method load.
/**
* {@inheritDoc}
*/
@Override
protected void load(final ModelContentRO model, final PortObjectSpec spec, final ExecutionMonitor exec) throws InvalidSettingsException {
final Config modelConfig = model.getConfig(CNFG_MODEL);
m_model = new NaiveBayesModel(modelConfig);
m_portSpec = spec;
}
Aggregations