use of org.knime.base.node.mine.treeensemble2.model.MultiClassGradientBoostedTreesModel in project knime-core by knime.
the class LKGradientBoostingPredictorCellFactory method createFactory.
public static LKGradientBoostingPredictorCellFactory createFactory(final GradientBoostingPredictor<MultiClassGradientBoostedTreesModel> predictor) throws InvalidSettingsException {
TreeEnsemblePredictorConfiguration config = predictor.getConfiguration();
DataTableSpec testSpec = predictor.getDataSpec();
TreeEnsembleModelPortObjectSpec modelSpec = predictor.getModelSpec();
ArrayList<DataColumnSpec> newColSpecs = new ArrayList<DataColumnSpec>();
UniqueNameGenerator nameGen = new UniqueNameGenerator(testSpec);
newColSpecs.add(nameGen.newColumn(config.getPredictionColumnName(), StringCell.TYPE));
if (config.isAppendPredictionConfidence()) {
newColSpecs.add(nameGen.newColumn("Confidence", DoubleCell.TYPE));
}
if (config.isAppendClassConfidences()) {
final String targetColName = modelSpec.getTargetColumn().getName();
final String suffix = config.getSuffixForClassProbabilities();
for (String val : modelSpec.getTargetColumnPossibleValueMap().keySet()) {
String colName = "P(" + targetColName + "=" + val + ")" + suffix;
newColSpecs.add(nameGen.newColumn(colName, DoubleCell.TYPE));
}
}
final Map<String, DataCell> targetValueMap = modelSpec.getTargetColumnPossibleValueMap();
return new LKGradientBoostingPredictorCellFactory(newColSpecs.toArray(new DataColumnSpec[newColSpecs.size()]), predictor.getModel(), modelSpec.getLearnTableSpec(), modelSpec.calculateFilterIndices(testSpec), config, targetValueMap);
}
Aggregations