Machine learning 什么';s scikit学习中Adaboost中使用的决策函数的定义(公式)
我发现,Machine learning 什么';s scikit学习中Adaboost中使用的决策函数的定义(公式),machine-learning,scikit-learn,Machine Learning,Scikit Learn,我发现,sklearn.employee.AdaBoostClassifier有一个方法decision\u函数 我认为这个函数应该返回一个与样本属于某个类别的可能性相关的值。我说得对吗 但是我在AdaBoostClassifier中找不到决策函数的公式,有人知道吗?它正好位于它应该位于的位置-在AdaBoostClassifier的源代码中,目前在639行 嗨,我找到了。但我指的是公式。或者换句话说,数学定义。无论如何谢谢你!我投票结束这个问题,因为它脱离主题(不是编程问题):OP请求skl
sklearn.employee.AdaBoostClassifier
有一个方法decision\u函数
我认为这个函数应该返回一个与样本属于某个类别的可能性相关的值。我说得对吗
但是我在
AdaBoostClassifier
中找不到决策函数的公式,有人知道吗?它正好位于它应该位于的位置-在AdaBoostClassifier的源代码中,目前在639行
嗨,我找到了。但我指的是公式。或者换句话说,数学定义。无论如何谢谢你!我投票结束这个问题,因为它脱离主题(不是编程问题):OP请求sklearn函数中使用的数学公式。
def decision_function(self, X):
"""Compute the decision function of ``X``.
Parameters
----------
X : {array-like, sparse matrix} of shape = [n_samples, n_features]
The training input samples. Sparse matrix can be CSC, CSR, COO,
DOK, or LIL. DOK and LIL are converted to CSR.
Returns
-------
score : array, shape = [n_samples, k]
The decision function of the input samples. The order of
outputs is the same of that of the `classes_` attribute.
Binary classification is a special cases with ``k == 1``,
otherwise ``k==n_classes``. For binary classification,
values closer to -1 or 1 mean more like the first or second
class in ``classes_``, respectively.
"""
check_is_fitted(self, "n_classes_")
X = self._validate_X_predict(X)
n_classes = self.n_classes_
classes = self.classes_[:, np.newaxis]
pred = None
if self.algorithm == 'SAMME.R':
# The weights are all 1. for SAMME.R
pred = sum(_samme_proba(estimator, n_classes, X)
for estimator in self.estimators_)
else: # self.algorithm == "SAMME"
pred = sum((estimator.predict(X) == classes).T * w
for estimator, w in zip(self.estimators_,
self.estimator_weights_))
pred /= self.estimator_weights_.sum()
if n_classes == 2:
pred[:, 0] *= -1
return pred.sum(axis=1)
return pred