use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class CrosstabNodeModel method loadInternals.
/**
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException {
if (m_settings.getEnableHiliting()) {
final NodeSettingsRO config = NodeSettings.loadFromXML(new FileInputStream(new File(nodeInternDir, INTERNALS_FILE_NAME)));
try {
setHiliteMapping(DefaultHiLiteMapper.load(config));
m_hilite.addToHiLiteHandler(getInHiLiteHandler(0));
} catch (final InvalidSettingsException ex) {
throw new IOException(ex.getMessage());
}
}
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class ValueCounterNodeModel method loadInternals.
/**
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
File f = new File(nodeInternDir, "Hiliting.conf.gz");
if (f.exists() && f.canRead()) {
InputStream in = new GZIPInputStream(new BufferedInputStream(new FileInputStream(f)));
NodeSettingsRO s = NodeSettings.loadFromXML(in);
in.close();
try {
m_translator.setMapper(DefaultHiLiteMapper.load(s));
} catch (InvalidSettingsException ex) {
throw new IOException(ex);
}
}
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class BasisFunctionLearnerNodeModel method loadInternals.
/**
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File internDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
// load model info
exec.checkCanceled();
exec.setProgress(0.1, "Loading model information");
File file = new File(internDir, MODEL_INFO_FILE_NAME);
m_modelInfo = (ModelContent) ModelContent.loadFromXML(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file))));
// load hilite mapping
exec.checkCanceled();
exec.setProgress(0.5, "Loading hilite mapping");
File mappingFile = new File(internDir, HILITE_MAPPING_FILE_NAME);
NodeSettingsRO mapSettings = NodeSettings.loadFromXML(new GZIPInputStream(new BufferedInputStream(new FileInputStream(mappingFile))));
try {
m_translator.setMapper(DefaultHiLiteMapper.load(mapSettings));
} catch (InvalidSettingsException ise) {
throw new IOException(ise.getMessage());
}
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class PolyRegLearnerSettings method loadSettingsFrom.
/**
* Loads the settings from the node settings object.
*
* @param settings the node settings
*
* @throws InvalidSettingsException if one of the settings is missing
*/
public void loadSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
m_degree = settings.getInt("degree");
m_targetColumn = settings.getString("targetColumn");
m_maxRowsForView = settings.getInt("maxViewRows");
// added v2.1
boolean includeAll = settings.getBoolean("includeAll", false);
// added in 2.10
m_missingValueHandling = MissingValueHandling.valueOf(settings.getString(CFG_MISSING_VALUE_HANDLING, MissingValueHandling.ignore.name()));
if (settings.containsKey("selectedColumns")) {
// removed in 2.10
String[] included = settings.getStringArray("selectedColumns");
// we were able to load the old settings
String[] excluded = new String[0];
// but convert to new:
NodeSettings fakeSettings = createFakeSettings(m_filterConfiguration.getConfigRootName(), included, excluded, includeAll);
// added in 2.10
m_filterConfiguration.loadConfigurationInModel(fakeSettings);
} else {
// no previous config: we should use the new config
// added in 2.10
NodeSettingsRO filterSettings = settings.getNodeSettings(m_filterConfiguration.getConfigRootName());
NodeSettingsRO dtSettings = filterSettings.getNodeSettings("datatype");
NodeSettingsRO tlSettings = dtSettings.getNodeSettings("typelist");
if (!tlSettings.keySet().contains(DoubleValue.class.getName())) {
NodeSettings fakeSettings = createFakeSettings(m_filterConfiguration.getConfigRootName(), new String[0], new String[0], false);
m_filterConfiguration.loadConfigurationInModel(fakeSettings);
} else {
m_filterConfiguration.loadConfigurationInModel(settings);
}
}
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class PolyRegLearnerNodeModel method loadInternals.
/**
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
File f = new File(nodeInternDir, "data.zip");
final DataArray rowContainer;
if (f.exists()) {
ContainerTable t = DataContainer.readFromZip(f);
int rowCount = t.getRowCount();
rowContainer = new DefaultDataArray(t, 1, rowCount, exec);
} else {
throw new FileNotFoundException("Internals do not exist");
}
f = new File(nodeInternDir, "internals.xml");
if (f.exists()) {
NodeSettingsRO internals = NodeSettings.loadFromXML(new BufferedInputStream(new FileInputStream(f)));
try {
double[] betas = internals.getDoubleArray("betas");
String[] columnNames = internals.getStringArray("columnNames");
double squaredError = internals.getDouble("squaredError");
double adjustedR2 = internals.getDouble("adjustedSquaredError", Double.NaN);
double[] meanValues = internals.getDoubleArray("meanValues");
double[] emptyArray = new double[betas.length];
Arrays.fill(emptyArray, Double.NaN);
double[] stdErrs = internals.getDoubleArray("stdErrors", emptyArray);
double[] tValues = internals.getDoubleArray("tValues", emptyArray);
double[] pValues = internals.getDoubleArray("pValues", emptyArray);
m_viewData = new PolyRegViewData(meanValues, betas, stdErrs, tValues, pValues, squaredError, adjustedR2, columnNames, m_settings.getDegree(), m_settings.getTargetColumn(), rowContainer);
} catch (InvalidSettingsException ex) {
throw new IOException("Old or corrupt internals", ex);
}
} else {
throw new FileNotFoundException("Internals do not exist");
}
}
Aggregations