use of org.knime.core.node.ModelContentRO in project knime-core by knime.
the class NumericOutlierPortObject method load.
/**
* {@inheritDoc}
*/
@Override
protected void load(final ModelContentRO model, final PortObjectSpec spec, final ExecutionMonitor exec) throws InvalidSettingsException, CanceledExecutionException {
// load the summary
m_summary = model.getString(CFG_SUMMARY);
// load the types
m_groupColTypes = model.getDataTypeArray(CFG_GROUP_COL_TYPES);
// initialize the reviser builder
final ModelContentRO reviserModel = model.getModelContent(CFG_REVISER);
// load the reviser settings
m_treatmentOption = NumericOutliersTreatmentOption.getEnum(reviserModel.getString(CFG_OUTLIER_TREATMENT));
m_repStrategy = NumericOutliersReplacementStrategy.getEnum(reviserModel.getString(CFG_OUTLIER_REPLACEMENT));
m_detectionOption = NumericOutliersDetectionOption.getEnum(reviserModel.getString(CFG_DETECTION_OPTION));
m_updateDomain = reviserModel.getBoolean(CFG_DOMAIN_POLICY);
// initialize the permitted intervals model
m_outlierModel = NumericOutliersModel.loadInstance(model.getModelContent(CFG_INTERVALS));
}
use of org.knime.core.node.ModelContentRO in project knime-core by knime.
the class MemberCounter method loadInstance.
/**
* Load a member counter from the provided model content.
*
* @param model the model content
* @return the proper initialized member counter
* @throws InvalidSettingsException if the input settings cannot be parsed
*/
@SuppressWarnings("unchecked")
static MemberCounter loadInstance(final ModelContentRO model) throws InvalidSettingsException {
// init the counter
final MemberCounter counter = new MemberCounter();
// load all the data
final Enumeration<ModelContentRO> colSettings = model.children();
while (colSettings.hasMoreElements()) {
final ModelContentRO colSetting = colSettings.nextElement();
final String outlierColName = colSetting.getString(CFG_OUT_COL_NAME);
final Enumeration<ModelContentRO> groupCounts = colSetting.getModelContent(CFG_GROUP_COUNTS).children();
while (groupCounts.hasMoreElements()) {
final ModelContentRO groupCount = groupCounts.nextElement();
final GroupKey key = new GroupKey(groupCount.getDataCellArray(CFG_GROUP_KEY));
final int count = groupCount.getInt(CFG_GROUP_VAL);
counter.incrementMemberCount(outlierColName, key, count);
}
}
// return the counter
return counter;
}
use of org.knime.core.node.ModelContentRO in project knime-core by knime.
the class NaiveBayesLearnerNodeModel method loadInternals.
/**
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException {
final File modelFile = new File(nodeInternDir, CFG_DATA);
final FileInputStream modelIn = new FileInputStream(modelFile);
// because the loadFromXML method returns the content of the root tag
// we don't need to ask for the content of the root tag
final ModelContentRO myModel = ModelContent.loadFromXML(modelIn);
try {
m_model = new NaiveBayesModel(myModel);
} catch (final Exception e) {
throw new IOException(e.getMessage());
}
}
use of org.knime.core.node.ModelContentRO in project knime-core by knime.
the class LogRegLearnerNodeModel method loadInternals.
/**
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File internDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
File inFile = new File(internDir, FILE_SAVE);
ModelContentRO c = ModelContent.loadFromXML(new BufferedInputStream(new GZIPInputStream(new FileInputStream(inFile))));
try {
ModelContentRO specContent = c.getModelContent(CFG_SPEC);
DataTableSpec spec = DataTableSpec.load(specContent);
ModelContentRO parContent = c.getModelContent(CFG_LOGREG_CONTENT);
m_content = LogisticRegressionContent.load(parContent, spec);
} catch (InvalidSettingsException ise) {
IOException ioe = new IOException("Unable to restore state: " + ise.getMessage());
ioe.initCause(ise);
throw ioe;
}
}
use of org.knime.core.node.ModelContentRO in project knime-core by knime.
the class LogRegLearnerNodeModel method loadInternals.
/**
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File internDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
File inFile = new File(internDir, FILE_SAVE);
ModelContentRO c = ModelContent.loadFromXML(new BufferedInputStream(new GZIPInputStream(new FileInputStream(inFile))));
try {
ModelContentRO specContent = c.getModelContent(CFG_SPEC);
DataTableSpec spec = DataTableSpec.load(specContent);
ModelContentRO parContent = c.getModelContent(CFG_LOGREG_CONTENT);
m_content = LogisticRegressionContent.load(parContent, spec);
} catch (InvalidSettingsException ise) {
IOException ioe = new IOException("Unable to restore state: " + ise.getMessage());
ioe.initCause(ise);
throw ioe;
}
}
Aggregations