sklearn.tree.
DecisionTreeRegressor
(criterion='mse', 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, presort=False)[source]¶A decision tree regressor.
Read more in the User Guide.
Note: the search for a split does not stop until at least one
valid partition of the node samples is found, even if it requires to
effectively inspect more than max_features
features.
max_leaf_nodes
is not None.max_leaf_nodes
in best-first fashion.
Best nodes are defined as relative reduction in impurity.
If None then unlimited number of leaf nodes.
If not None then max_depth
will be ignored.fit
is performed.fit
is performed.DecisionTreeClassifier
[1] | http://en.wikipedia.org/wiki/Decision_tree_learning |
[2] | L. Breiman, J. Friedman, R. Olshen, and C. Stone, “Classification and Regression Trees”, Wadsworth, Belmont, CA, 1984. |
[3] | T. Hastie, R. Tibshirani and J. Friedman. “Elements of Statistical Learning”, Springer, 2009. |
[4] | L. Breiman, and A. Cutler, “Random Forests”, http://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm |
>>> from sklearn.datasets import load_boston
>>> from sklearn.cross_validation import cross_val_score
>>> from sklearn.tree import DecisionTreeRegressor
>>> boston = load_boston()
>>> regressor = DecisionTreeRegressor(random_state=0)
>>> cross_val_score(regressor, boston.data, boston.target, cv=10)
...
...
array([ 0.61..., 0.57..., -0.34..., 0.41..., 0.75...,
0.07..., 0.29..., 0.33..., -1.42..., -1.77...])
__init__
(criterion='mse', 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, presort=False)[source]¶Methods
__init__ ([criterion, splitter, max_depth, ...]) |
|
apply (X[, check_input]) |
Returns the index of the leaf that each sample is predicted as. |
fit (X, y[, sample_weight, check_input, ...]) |
Build a decision tree from the training set (X, y). |
fit_transform (X[, y]) |
Fit to data, then transform it. |
get_params ([deep]) |
Get parameters for this estimator. |
predict (X[, check_input]) |
Predict class or regression value for X. |
score (X, y[, sample_weight]) |
Returns the coefficient of determination R^2 of the prediction. |
set_params (**params) |
Set the parameters of this estimator. |
transform (*args, **kwargs) |
DEPRECATED: Support to use estimators as feature selectors will be removed in version 0.19. |
Attributes
feature_importances_ |
Return the feature importances. |