public class DecisionTreeClassificationModel extends ProbabilisticClassificationModel<Vector,DecisionTreeClassificationModel> implements DecisionTreeModel, DecisionTreeClassifierParams, MLWritable, scala.Serializable
Modifier and Type | Method and Description |
---|---|
DecisionTreeClassificationModel |
copy(ParamMap extra)
Creates a copy of this instance with the same UID and some extra params.
|
Vector |
featureImportances()
Estimate of the importance of each feature.
|
static DecisionTreeClassificationModel |
load(String path) |
int |
numClasses()
Number of classes (values which the label can take).
|
int |
numFeatures()
Returns the number of features the model was trained on.
|
double |
predict(Vector features)
Predict label for the given features.
|
static MLReader<DecisionTreeClassificationModel> |
read() |
Node |
rootNode()
Root of the decision tree
|
String |
toString()
Summary of the model
|
String |
uid()
An immutable unique ID for the object and its derivatives.
|
MLWriter |
write()
Returns an
MLWriter instance for this ML instance. |
normalizeToProbabilitiesInPlace, setProbabilityCol, setThresholds, transform
setRawPredictionCol
setFeaturesCol, setPredictionCol, transformSchema
transform, transform, transform
depth, maxSplitFeatureIndex, numNodes, toDebugString
cacheNodeIds, getCacheNodeIds, getMaxBins, getMaxDepth, getMaxMemoryInMB, getMinInfoGain, getMinInstancesPerNode, getOldStrategy, maxBins, maxDepth, maxMemoryInMB, minInfoGain, minInstancesPerNode, setCacheNodeIds, setCheckpointInterval, setMaxBins, setMaxDepth, setMaxMemoryInMB, setMinInfoGain, setMinInstancesPerNode, setSeed
validateAndTransformSchema
getLabelCol, labelCol
featuresCol, getFeaturesCol
getPredictionCol, predictionCol
clear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn
checkpointInterval, getCheckpointInterval
getImpurity, getOldImpurity, impurity, setImpurity
save
validateAndTransformSchema
getRawPredictionCol, rawPredictionCol
getProbabilityCol, probabilityCol
getThresholds, thresholds
initializeLogging, initializeLogIfNecessary, initializeLogIfNecessary, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
public static MLReader<DecisionTreeClassificationModel> read()
public static DecisionTreeClassificationModel load(String path)
public String uid()
Identifiable
uid
in interface Identifiable
public Node rootNode()
DecisionTreeModel
rootNode
in interface DecisionTreeModel
public int numFeatures()
PredictionModel
numFeatures
in class PredictionModel<Vector,DecisionTreeClassificationModel>
public int numClasses()
ClassificationModel
numClasses
in class ClassificationModel<Vector,DecisionTreeClassificationModel>
public double predict(Vector features)
ClassificationModel
transform()
and output predictionCol
.
This default implementation for classification predicts the index of the maximum value
from predictRaw()
.
predict
in class ClassificationModel<Vector,DecisionTreeClassificationModel>
features
- (undocumented)public DecisionTreeClassificationModel copy(ParamMap extra)
Params
defaultCopy()
.copy
in interface Params
copy
in class Model<DecisionTreeClassificationModel>
extra
- (undocumented)public String toString()
DecisionTreeModel
toString
in interface DecisionTreeModel
toString
in interface Identifiable
toString
in class Object
public Vector featureImportances()
This generalizes the idea of "Gini" importance to other losses, following the explanation of Gini importance from "Random Forests" documentation by Leo Breiman and Adele Cutler, and following the implementation from scikit-learn.
This feature importance is calculated as follows: - importance(feature j) = sum (over nodes which split on feature j) of the gain, where gain is scaled by the number of instances passing through node - Normalize importances for tree to sum to 1.
RandomForestClassifier
to determine feature importance instead.public MLWriter write()
MLWritable
MLWriter
instance for this ML instance.write
in interface MLWritable