Python sklearn.employee.GradientBoostingClassifier.predict()是如何工作的?

2024-05-16 07:08:53 发布

您现在位置:Python中文网/ 问答频道 /正文

Pythonsklearn.ensemble.GradientBoostingClassifier.predict()是如何工作的

将实例分配到目标级别的predict()阈值是多少?假设,目标是1234,并且目标1/2/3/4的实例的预测概率是0.2/0.5/0.1/0.2predict()是否将此实例分配给目标级别2

下面是源代码。如何逐行或逐块解释它?我还附上了predict()及其源代码的链接

def predict(self, X):
    """Predict class for X.
    Parameters
    ----------
    X : {array-like, 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 sparse ``csr_matrix``.
    Returns
    -------
    y : array, shape (n_samples,)
        The predicted values.
    """
    raw_predictions = self.decision_function(X)
    encoded_labels = \
        self.loss_._raw_prediction_to_decision(raw_predictions)
    return self.classes_.take(encoded_labels, axis=0)

Tags: to实例self目标rawsklearnscikit级别