Difference between revisions of "sklearn.tree.DecisionTreeClassifier"

From GM-RKB
Jump to: navigation, search
m (Text replacement - "</B>[[" to "</B> [[")
m (Remove links to pages that are actually redirects to this page.)
 
Line 2: Line 2:
 
* <B>Context</B>
 
* <B>Context</B>
 
** Usage:   
 
** Usage:   
::: 1) Import [[Classification Tree Learning System]] from [[scikit-learn]] : <code>from [[sklearn.tree]] import [[DecisionTreeClassifier]]</code>
+
::: 1) Import [[Classification Tree Learning System]] from [[scikit-learn]] : <code>from [[sklearn.tree]] import [[sklearn.tree.DecisionTreeClassifier|DecisionTreeClassifier]]</code>
 
::: 2) Create [[design matrix]] <code>X</code> and [[response vector]] <code>Y</code>   
 
::: 2) Create [[design matrix]] <code>X</code> and [[response vector]] <code>Y</code>   
::: 3) Create [[Decision Tree Classifier]] object: <code>DTclf=[[DecisionTreeClassifier]](criterion=’gini’, splitter=’best’[, max_depth=None, min_samples_split=2, min_samples_leaf=1,...])</code>
+
::: 3) Create [[Decision Tree Classifier]] object: <code>DTclf=[[sklearn.tree.DecisionTreeClassifier|DecisionTreeClassifier]](criterion=’gini’, splitter=’best’[, max_depth=None, min_samples_split=2, min_samples_leaf=1,...])</code>
 
::: 4)  Choose method(s):
 
::: 4)  Choose method(s):
 
::::* <code>DTclf</code>.<code>apply(X[, check_input])</code>, returns the leaf index for each sample predictor.
 
::::* <code>DTclf</code>.<code>apply(X[, check_input])</code>, returns the leaf index for each sample predictor.
Line 31: Line 31:
 
=== 2017b ===
 
=== 2017b ===
 
* (Scikit-Learn, 2017B) &rArr; http://scikit-learn.org/stable/modules/tree.html#classification
 
* (Scikit-Learn, 2017B) &rArr; http://scikit-learn.org/stable/modules/tree.html#classification
** QUOTE: [[DecisionTreeClassifier]] is a [[class]] capable of performing [[multi-class classification]] on a [[dataset]].        <P>        As with other [[classifier]]s, [[DecisionTreeClassifier]] takes as input two arrays: an array X, sparse or dense, of size <code>[n_samples, n_features]</code> holding the [[training sample]]s, and an array Y of integer values, size <code>[n_samples]</code>, holding the class labels for the training samples:
+
** QUOTE: [[sklearn.tree.DecisionTreeClassifier|DecisionTreeClassifier]] is a [[class]] capable of performing [[multi-class classification]] on a [[dataset]].        <P>        As with other [[classifier]]s, [[sklearn.tree.DecisionTreeClassifier|DecisionTreeClassifier]] takes as input two arrays: an array X, sparse or dense, of size <code>[n_samples, n_features]</code> holding the [[training sample]]s, and an array Y of integer values, size <code>[n_samples]</code>, holding the class labels for the training samples:
 
----
 
----
 
__NOTOC__
 
__NOTOC__
 
[[Category:Concept]]
 
[[Category:Concept]]

Latest revision as of 20:45, 23 December 2019

A sklearn.tree.DecisionTreeClassifier is a classification tree learning system within sklearn.tree.

  • Context
    • Usage:
1) Import Classification Tree Learning System from scikit-learn : from sklearn.tree import DecisionTreeClassifier
2) Create design matrix X and response vector Y
3) Create Decision Tree Classifier object: DTclf=DecisionTreeClassifier(criterion=’gini’, splitter=’best’[, max_depth=None, min_samples_split=2, min_samples_leaf=1,...])
4) Choose method(s):
  • DTclf.apply(X[, check_input]), returns the leaf index for each sample predictor.
  • DTclf.decision_path(X[, check_input]), returns the decision path in the tree.
  • DTclf.fit(X, y[, sample_weight, check_input,...]) builds a decision tree classifier from the training set (X, y).
  • DTclf.get_params([deep]) returns parameters for this estimator.
  • DTclf.predict(X[, check_input]), predicts class for X.
  • DTclf.predict_log_proba(X), predicts class log-probabilities of the input samples X.
  • DTclf.predict_proba(X[, check_input]), predicts class probabilities of the input samples X.
  • DTclf.score(X, y[, sample_weight]), returns the mean accuracy on the given test data and labels.
  • DTclf.set_params(**params), sets the parameters of this estimator.


References

2017a

  • (Scikit-Learn, 2017A) ⇒ http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html Retrieved:2017-10-22
    • QUOTE: class sklearn.tree.DecisionTreeClassifier(criterion=’gini’, splitter=’best’, max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=None, random_state=None, max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, class_weight=None, presort=False)

      A decision tree classifier.

      Read more in the User Guide.

2017b