简体   繁体   English

scikit-learn 中 Adaboost 中使用的决策函数的定义(公式)是什么

[英]what's the definition ( formula) for decision function used in Adaboost in scikit-learn

I find that sklearn.ensemble.AdaBoostClassifier there is a method decision_function .我发现sklearn.ensemble.AdaBoostClassifier有一个方法decision_function

I think this function should return a value related to the possibility of a sample belongs to a category.我认为这个函数应该返回一个与样本属于某个类别的可能性相关的值。 Am I right?我对吗?

But I can't find the formula for decision function in AdaBoostClassifier , does anyone know that?但是我在AdaBoostClassifier找不到决策函数的公式,有人知道吗?

It is located exactly where it is supposed to be - in the source of AdaBoostClassifier, currently in the line 639它正好位于它应该在的位置 - 在 AdaBoostClassifier 的源代码中,目前在第 639 行

https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/ensemble/weight_boosting.py#L639 https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/ensemble/weight_boosting.py#L639

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 scikit-learn的adaboost中的体重问题 - weight issues in scikit-learn's adaboost scikit-learn 上逻辑回归的决策 function 是如何工作的? - How decision function of Logistic Regression on scikit-learn works? 如何在OpenCV和SciKit-learn中实现Adaboost的等效版本? - How to implement an equivalent version of Adaboost in OpenCV and SciKit-learn? scikit-learn中决策树中的AUC计算 - AUC calculation in decision tree in scikit-learn 如何在 scikit-learn 中使用具有不同基础估计器的 adaboost? - How to use adaboost with different base estimator in scikit-learn? 使用scikit-learning SVC决策函数预测概率,其中Decision_function_shape ='ovo' - Predicting probability from scikit-learn SVC decision_function with decision_function_shape='ovo' scikit-learn 算法用于多类分类的默认机制是什么? - What is the default mechanism used by scikit-learn algorithms for multiclass classification? 在scikit-learn管道中使用transformer_weights有什么用? - what's the use of transformer_weights in scikit-learn pipeline? Scikit-Learn的SVM类中nu参数的含义是什么? - What is the meaning of the nu parameter in Scikit-Learn's SVM class? SciKit-learn的“预测”功能以错误的格式输出 - SciKit-learn's 'predict' function giving output in wrong format
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM