use of org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.
the class RandomForestRegressionLearnerNodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
final DataTableSpec inSpec = specs[0];
TreeEnsembleLearnerConfiguration cfg = new TreeEnsembleLearnerConfiguration(true);
cfg.loadInDialog(settings, inSpec);
m_optionsPanel.loadSettingsFrom(inSpec, cfg);
}
use of org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.
the class RegressionTreeLearnerNodeDialogPane method saveSettingsTo.
/**
* {@inheritDoc}
*/
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
TreeEnsembleLearnerConfiguration cfg = new TreeEnsembleLearnerConfiguration(true);
m_optionsPanel.saveSettings(cfg);
cfg.save(settings);
}
use of org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.
the class RegressionTreeLearnerNodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
final DataTableSpec inSpec = specs[0];
TreeEnsembleLearnerConfiguration cfg = new TreeEnsembleLearnerConfiguration(true);
cfg.loadInDialog(settings, inSpec);
m_optionsPanel.loadSettingsFrom(inSpec, cfg);
}
use of org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.
the class RegressionTreeLearnerNodeModel method loadValidatedSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
TreeEnsembleLearnerConfiguration config = new TreeEnsembleLearnerConfiguration(true);
config.loadInModel(settings);
m_configuration = config;
}
use of org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.
the class TreeLearnerClassification method buildTreeNode.
private TreeNodeClassification buildTreeNode(final ExecutionMonitor exec, final int currentDepth, final double[] rowSampleWeights, final TreeNodeSignature treeNodeSignature, final ClassificationPriors targetPriors, final BitSet forbiddenColumnSet, final TreeNodeMembershipController membershipController) throws CanceledExecutionException {
final TreeData data = getData();
final TreeEnsembleLearnerConfiguration config = getConfig();
exec.checkCanceled();
SplitCandidate bestSplit = findBestSplitClassification(currentDepth, rowSampleWeights, treeNodeSignature, targetPriors, forbiddenColumnSet, membershipController);
if (bestSplit == null) {
return new TreeNodeClassification(treeNodeSignature, targetPriors, getConfig());
}
TreeAttributeColumnData splitColumn = bestSplit.getColumnData();
final int attributeIndex = splitColumn.getMetaData().getAttributeIndex();
boolean markAttributeAsForbidden = !bestSplit.canColumnBeSplitFurther();
forbiddenColumnSet.set(attributeIndex, markAttributeAsForbidden);
TreeNodeCondition[] childConditions = bestSplit.getChildConditions();
if (childConditions.length > Short.MAX_VALUE) {
throw new RuntimeException("Too many children when splitting " + "attribute " + bestSplit.getColumnData() + " (maximum supported: " + Short.MAX_VALUE + "): " + childConditions.length);
}
TreeNodeClassification[] childNodes = new TreeNodeClassification[childConditions.length];
final double[] dataMemberships = rowSampleWeights;
// final double[] dataMemberships = rowSampleWeights.getMemberships();
final double[] childMemberships = new double[dataMemberships.length];
final TreeTargetNominalColumnData targetColumn = (TreeTargetNominalColumnData) data.getTargetColumn();
for (int i = 0; i < childConditions.length; i++) {
System.arraycopy(dataMemberships, 0, childMemberships, 0, dataMemberships.length);
TreeNodeCondition cond = childConditions[i];
splitColumn.updateChildMemberships(cond, dataMemberships, childMemberships);
// TreeNodeMembershipController childMembershipController = membershipController.createChildTreeNodeMembershipController(childMemberships);
TreeNodeMembershipController childMembershipController = null;
ClassificationPriors childTargetPriors = targetColumn.getDistribution(childMemberships, config);
TreeNodeSignature childSignature = treeNodeSignature.createChildSignature((short) i);
childNodes[i] = buildTreeNode(exec, currentDepth + 1, childMemberships, childSignature, childTargetPriors, forbiddenColumnSet, childMembershipController);
childNodes[i].setTreeNodeCondition(cond);
}
if (markAttributeAsForbidden) {
forbiddenColumnSet.set(attributeIndex, false);
}
return new TreeNodeClassification(treeNodeSignature, targetPriors, childNodes, getConfig());
}
Aggregations