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.addDataType(CLASS_COL_TYPE, m_classColType);
predParams.addBoolean(IGNORE_MISSING_VALS, m_ignoreMissingVals);
predParams.addDouble(THRESHOLD, m_pmmlZeroProbThreshold.doubleValue());
// 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 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 NumericalAttributeModel method saveModelInternal.
/**
* {@inheritDoc}
*/
@Override
void saveModelInternal(final Config config) {
config.addInt(CLASS_VALUE_COUNTER, m_classValues.size());
int i = 0;
for (final NumericalClassValue 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 NominalAttributeModel method saveModelInternal.
/**
* {@inheritDoc}
*/
@Override
void saveModelInternal(final Config config) {
config.addInt(MAX_NO_OF_ATTRS, getMaxNoOfAttrVals());
config.addInt(CLASS_VALUE_COUNTER, m_classValues.size());
final String[] attrVals = m_attributeVals.toArray(new String[] {});
config.addStringArray(ATTRIBUTE_VALUES, attrVals);
int i = 0;
for (final NominalClassValue 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 VirtualSubNodeInputNodeFactory method loadPortTypeList.
/**
* @param config
* @return TODO
* @throws InvalidSettingsException
*/
static PortType[] loadPortTypeList(final ConfigRO config) throws InvalidSettingsException {
Set<String> keySet = config.keySet();
PortType[] outTypes = new PortType[keySet.size()];
for (String s : keySet) {
ConfigRO portConfig = config.getConfig(s);
int index = portConfig.getInt("index");
CheckUtils.checkSetting(index >= 0 && index < outTypes.length, "Invalid port index must be in [0, %d]: %d", keySet.size() - 1, index);
Config portTypeConfig = portConfig.getConfig("type");
PortType type = PortType.load(portTypeConfig);
outTypes[index] = type;
}
int invalidIndex = Arrays.asList(outTypes).indexOf(null);
if (invalidIndex >= 0) {
throw new InvalidSettingsException("Unassigned port type at index " + invalidIndex);
}
return outTypes;
}
Aggregations