use of org.knime.base.node.mine.svm.kernel.KernelFactory.KernelType in project knime-core by knime.
the class SVMLearnerNodeModel method loadValidatedSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
m_paramC.loadSettingsFrom(settings);
m_classcol.loadSettingsFrom(settings);
if (settings.containsKey(CFG_KERNELTYPE)) {
m_kernelType = KernelType.valueOf(settings.getString(CFG_KERNELTYPE));
}
for (Map.Entry<KernelType, Vector<SettingsModelDouble>> entry : m_kernelParameters.entrySet()) {
Vector<SettingsModelDouble> kernelsettings = entry.getValue();
for (SettingsModelDouble smd : kernelsettings) {
try {
smd.loadSettingsFrom(settings);
} catch (InvalidSettingsException ise) {
// it's not bad if a parameter is missing. This may be
// an old version, but inform the user.
LOGGER.warn("Did not find " + smd.toString() + " in the" + " NodeSettings. Using default value instead.");
}
}
}
}
use of org.knime.base.node.mine.svm.kernel.KernelFactory.KernelType in project knime-core by knime.
the class SVMLearnerNodeModel method createKernelParams.
/**
* creates the kernel parameter SettingsModels.
*
* @return HashMap containing the kernel and its assigned SettingsModels.
*/
static LinkedHashMap<KernelType, Vector<SettingsModelDouble>> createKernelParams() {
LinkedHashMap<KernelType, Vector<SettingsModelDouble>> kernelParameters = new LinkedHashMap<KernelType, Vector<SettingsModelDouble>>();
for (KernelType kerneltype : KernelType.values()) {
Kernel kernel = KernelFactory.getKernel(kerneltype);
Vector<SettingsModelDouble> settings = new Vector<SettingsModelDouble>();
for (int i = 0; i < kernel.getNumberParameters(); i++) {
settings.add(new SettingsModelDouble(CFG_KERNELPARAM + "_" + kernel.getParameterName(i), kernel.getDefaultParameter(i)));
}
kernelParameters.put(kerneltype, settings);
}
return kernelParameters;
}
use of org.knime.base.node.mine.svm.kernel.KernelFactory.KernelType in project knime-core by knime.
the class SVMLearnerNodeModel method saveSettingsTo.
/**
* {@inheritDoc}
*/
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) {
settings.addString(CFG_KERNELTYPE, m_kernelType.toString());
m_paramC.saveSettingsTo(settings);
m_classcol.saveSettingsTo(settings);
for (Map.Entry<KernelType, Vector<SettingsModelDouble>> entry : m_kernelParameters.entrySet()) {
Vector<SettingsModelDouble> kernelsettings = entry.getValue();
for (SettingsModelDouble smd : kernelsettings) {
smd.saveSettingsTo(settings);
}
}
}
use of org.knime.base.node.mine.svm.kernel.KernelFactory.KernelType in project knime-core by knime.
the class SVMLearnerNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
if (settings.containsKey(CFG_KERNELTYPE)) {
String tmpKernel = settings.getString(CFG_KERNELTYPE);
boolean found = false;
for (String kernel : KernelFactory.getKernelNames()) {
if (tmpKernel.equals(kernel)) {
found = true;
}
}
if (!found) {
throw new InvalidSettingsException("Unknown kernel type: " + tmpKernel);
}
}
for (Map.Entry<KernelType, Vector<SettingsModelDouble>> entry : m_kernelParameters.entrySet()) {
Vector<SettingsModelDouble> kernelsettings = entry.getValue();
for (SettingsModelDouble smd : kernelsettings) {
try {
smd.validateSettings(settings);
} catch (InvalidSettingsException ise) {
// it's not bad if a parameter is missing. This may be
// an old version, but inform the user.
LOGGER.warn("Did not find " + smd.toString() + " in the" + " NodeSettings. Using default value instead.");
}
}
}
m_paramC.validateSettings(settings);
m_classcol.validateSettings(settings);
}
Aggregations