Pythonsklearn.ensemble.GradientBoostingClassifier.predict()
是如何工作的
将实例分配到目标级别的predict()
阈值是多少?假设,目标是1
、2
、3
或4
,并且目标1/2/3/4
的实例的预测概率是0.2/0.5/0.1/0.2
。predict()
是否将此实例分配给目标级别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)
目前没有回答
相关问题 更多 >
编程相关推荐