1.10. Decision Trees : sklearn.tree.DecisionTreeClassifier
来源:互联网 发布:centos 6关闭防火墙 编辑:程序博客网 时间:2024/06/05 01:50
apply
(X, check_input=True)[source]Returns the index of the leaf that each sample is predicted as.
返回预测样本所在叶子节点的索引。
X : array_like or sparse matrix, shape = [n_samples, n_features]
The input samples. Internally, it will be converted to
dtype=np.float32
and if a sparse matrix is provided to a sparsecsr_matrix
.
check_input : boolean, (default=True)
Allow to bypass several input checking. Don’t use this parameter unless you know what you do.
X_leaves : array_like, shape = [n_samples,]
For each datapoint x in X, return the index of the leaf x ends up in. Leaves are numbered within
[0; self.tree_.node_count)
, possibly with gaps in the numbering
decision_path
(X, check_input=True)[source]Return the decision path in the tree
返回在决策树中的决策路径。
New in version 0.18.
X : array_like or sparse matrix, shape = [n_samples, n_features]
The input samples. Internally, it will be converted to
dtype=np.float32
and if a sparse matrix is provided to a sparsecsr_matrix
.
check_input : boolean, (default=True)
Allow to bypass several input checking. Don’t use this parameter unless you know what you do.
indicator : sparse csr array, shape = [n_samples, n_nodes]
Return a node indicator matrix where non zero elements indicates that the samples goes through the nodes.
feature_importances_
Return the feature importances.
返回特征的重要性
The importance of a feature is computed as the (normalized) total reduction of the criterion brought by that feature. It is also known as the Gini importance.(并不是很懂)
fit
(X, y, sample_weight=None, check_input=True, X_idx_sorted=None)[source]Build a decision tree classifier from the training set (X, y).
使用训练集来构建决策树分类器。
X : array-like or sparse matrix, shape = [n_samples, n_features]
The training input samples. Internally, it will be converted to
dtype=np.float32
and if a sparse matrix is provided to a sparsecsc_matrix
.
y : array-like, shape = [n_samples] or [n_samples, n_outputs]
The target values (class labels) as integers or strings.
sample_weight : array-like, shape = [n_samples] or None
Sample weights. If None, then samples are equally weighted. Splits that would create child nodes with net zero or negative weight are ignored while searching for a split in each node. Splits are also ignored if they would result in any single class carrying a negative weight in either child node.
check_input : boolean, (default=True)
Allow to bypass several input checking. Don’t use this parameter unless you know what you do.
X_idx_sorted : array-like, shape = [n_samples, n_features], optional
The indexes of the sorted training input samples. If many tree are grown on the same dataset, this allows the ordering to be cached between trees. If None, the data will be sorted here. Don’t use this parameter unless you know what to do.
self : object
Returns self.
fit_transform
(X, y=None, **fit_params)[source]Fit to data, then transform it.
并不是很懂,而且好像要不能用了?
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
X : numpy array of shape [n_samples, n_features]
Training set.
y : numpy array of shape [n_samples]
Target values.
X_new : numpy array of shape [n_samples, n_features_new]
Transformed array.
get_params
(deep=True)[source]Get parameters for this estimator.
获得分类器的参数。
deep : boolean, optional
If True, will return the parameters for this estimator and contained subobjects that are estimators.
params : mapping of string to any
Parameter names mapped to their values.
predict
(X, check_input=True)[source]Predict class or regression value for X.
预测X的类别。
For a classification model, the predicted class for each sample in X is returned. For a regression model, the predicted value based on X is returned.
X : array-like or sparse matrix of shape = [n_samples, n_features]
The input samples. Internally, it will be converted to
dtype=np.float32
and if a sparse matrix is provided to a sparsecsr_matrix
.
check_input : boolean, (default=True)
Allow to bypass several input checking. Don’t use this parameter unless you know what you do.
y : array of shape = [n_samples] or [n_samples, n_outputs]
The predicted classes, or the predict values.
predict_log_proba
(X)[source]Predict classlog-probabilities of the input samples X.
(并不是很懂)
X : array-like or sparse matrix of shape = [n_samples, n_features]
The input samples. Internally, it will be converted to
dtype=np.float32
and if a sparse matrix is provided to a sparsecsr_matrix
.
p : array of shape = [n_samples, n_classes], or a list of n_outputs
such arrays if n_outputs > 1. The class log-probabilities of the input samples. The order of the classes corresponds to that in the attribute classes_.
predict_proba
(X, check_input=True)[source]Predict class probabilities of the input samples X.
预测输入样本X的类别概率。
The predicted class probability is the fraction of samples of the same class in a leaf.
- check_input: boolean, (default=True)
- Allow to bypass several input checking. Don’t use this parameter unless you know what you do.
X : array-like or sparse matrix of shape = [n_samples, n_features]
The input samples. Internally, it will be converted to
dtype=np.float32
and if a sparse matrix is provided to a sparsecsr_matrix
.
p : array of shape = [n_samples, n_classes], or a list of n_outputs
such arrays if n_outputs > 1. The class probabilities of the input samples. The order of the classes corresponds to that in the attribute classes_.
score
(X, y, sample_weight=None)[source]Returns the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
X : array-like, shape = (n_samples, n_features)
Test samples.
y : array-like, shape = (n_samples) or (n_samples, n_outputs)
True labels for X.
sample_weight : array-like, shape = [n_samples], optional
Sample weights.
score : float
Mean accuracy of self.predict(X) wrt. y.
set_params
(**params)[source]Set the parameters of this estimator.
设置分类器的参数。
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
- 1.10. Decision Trees : sklearn.tree.DecisionTreeClassifier
- sklearn.tree之Decision Trees
- sklearn decision-tree实验
- Python sklearn库中决策树tree.DecisionTreeClassifier()函数参数介绍
- 1.10. Decision Trees
- Decision Trees
- Decision Trees
- Decision Trees
- scikit-learn学习1.10. 决策树(Decision Trees)
- decision tree
- decision tree
- decision tree
- Decision Tree
- Decision Tree
- Decision Tree
- Decision Tree
- Decision Tree
- Decision Tree
- camel-spring项目启动过程
- 操作系统短作业优先(SJF)调度算法
- [JS]js区分浏览器与版本
- NoSuchFieldError: No static field btn_press3 of type I in class Lcom/hyphenate/helpdesk/R$id; or its
- HighChart如何自行设置x轴的名字和加载多条折线
- 1.10. Decision Trees : sklearn.tree.DecisionTreeClassifier
- 自定义字符串排序
- CentOS6.5上Cloud Control 12c安装
- 分治法求一个N个元素数组的逆序数
- stupid coding
- minGW安装和配置
- linux/ubuntu常用bash/shell命令
- .一个数组中只有两个数字是出现一次,其他所有数字都出现了两次。 找出这两个数字,编程实现。
- Ubuntu系统Spyder运行时kernel died问题