use of org.knime.base.node.mine.decisiontree2.model.DecisionTree in project knime-core by knime.
the class DecTreePredictorGraphView method modelChanged.
/**
* {@inheritDoc}
*/
@Override
protected void modelChanged() {
DecTreePredictorNodeModel model = this.getNodeModel();
if (model != null) {
m_hiLiteHdl.removeHiLiteListener(this);
DecisionTree dt = model.getDecisionTree();
if (dt != null) {
m_graph.setColorColumn(model.getDecisionTree().getColorColumn());
m_graph.setRootNode(dt.getRootNode());
// retrieve HiLiteHandler from Input port
m_hiLiteHdl = model.getInHiLiteHandler(DecTreePredictorNodeModel.INDATAPORT);
// and adjust menu entries for HiLite-ing
m_hiLiteMenu.setEnabled(m_hiLiteHdl != null);
m_hiLiteHdl.addHiLiteListener(this);
recreateHiLite();
} else {
m_graph.setColorColumn(null);
m_graph.setRootNode(null);
}
}
}
use of org.knime.base.node.mine.decisiontree2.model.DecisionTree in project knime-core by knime.
the class DecTreePredictorNodeModel method loadInternals.
/**
* Load internals.
*
* @param nodeInternDir The intern node directory to load tree from.
* @param exec Used to report progress or cancel saving.
* @throws IOException Always, since this method has not been implemented
* yet.
* @see org.knime.core.node.NodeModel
* #loadInternals(java.io.File,ExecutionMonitor)
*/
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException {
// read the decision tree
File internalsFile = new File(nodeInternDir, INTERNALS_FILE_NAME);
if (!internalsFile.exists()) {
// file to load internals from not available
setWarningMessage("Internal model could not be loaded.");
return;
}
BufferedInputStream in2 = new BufferedInputStream(new GZIPInputStream(new FileInputStream(internalsFile)));
ModelContentRO binModel = ModelContent.loadFromXML(in2);
try {
m_decTree = new DecisionTree(binModel);
} catch (InvalidSettingsException ise) {
LOGGER.warn("Model (internals) could not be loaded.", ise);
setWarningMessage("Internal model could not be loaded.");
}
}
use of org.knime.base.node.mine.decisiontree2.model.DecisionTree in project knime-core by knime.
the class TreeEnsembleModel method createDecisionTree.
public DecisionTree createDecisionTree(final int modelIndex, final DataTable sampleForHiliting) {
final DecisionTree result;
final TreeMetaData metaData = getMetaData();
if (metaData.isRegression()) {
TreeModelRegression treeModel = getTreeModelRegression(modelIndex);
result = treeModel.createDecisionTree(metaData);
} else {
TreeModelClassification treeModel = getTreeModelClassification(modelIndex);
result = treeModel.createDecisionTree(metaData);
}
if (sampleForHiliting != null) {
final DataTableSpec dataSpec = sampleForHiliting.getDataTableSpec();
final DataTableSpec spec = getLearnAttributeSpec(dataSpec);
for (DataRow r : sampleForHiliting) {
try {
DataRow fullAttributeRow = createLearnAttributeRow(r, spec);
result.addCoveredPattern(fullAttributeRow, spec);
} catch (Exception e) {
// dunno what to do with that
NodeLogger.getLogger(getClass()).error("Error updating hilite info in tree view", e);
break;
}
}
}
return result;
}
use of org.knime.base.node.mine.decisiontree2.model.DecisionTree in project knime-core by knime.
the class DecTreePredictorGraphView method modelChanged.
/**
* {@inheritDoc}
*/
@Override
protected void modelChanged() {
DecTreePredictorNodeModel model = this.getNodeModel();
if (model != null) {
m_hiLiteHdl.removeHiLiteListener(this);
DecisionTree dt = model.getDecisionTree();
if (dt != null) {
m_graph.setColorColumn(model.getDecisionTree().getColorColumn());
m_graph.setRootNode(dt.getRootNode());
// retrieve HiLiteHandler from Input port
m_hiLiteHdl = model.getInHiLiteHandler(DecTreePredictorNodeModel.INDATAPORT);
// and adjust menu entries for HiLite-ing
m_hiLiteMenu.setEnabled(m_hiLiteHdl != null);
m_hiLiteHdl.addHiLiteListener(this);
recreateHiLite();
} else {
m_graph.setColorColumn(null);
m_graph.setRootNode(null);
}
}
}
use of org.knime.base.node.mine.decisiontree2.model.DecisionTree in project knime-core by knime.
the class DecTreePredictorNodeModel method loadInternals.
/**
* Load internals.
*
* @param nodeInternDir The intern node directory to load tree from.
* @param exec Used to report progress or cancel saving.
* @throws IOException Always, since this method has not been implemented
* yet.
* @see org.knime.core.node.NodeModel
* #loadInternals(java.io.File,ExecutionMonitor)
*/
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException {
// read the decision tree
File internalsFile = new File(nodeInternDir, INTERNALS_FILE_NAME);
if (!internalsFile.exists()) {
// file to load internals from not available
setWarningMessage("Internal model could not be loaded.");
return;
}
BufferedInputStream in2 = new BufferedInputStream(new GZIPInputStream(new FileInputStream(internalsFile)));
ModelContentRO binModel = ModelContent.loadFromXML(in2);
try {
m_decTree = new DecisionTree(binModel);
} catch (InvalidSettingsException ise) {
LOGGER.warn("Model (internals) could not be loaded.", ise);
setWarningMessage("Internal model could not be loaded.");
}
}
Aggregations