By default, the score computed at each CV iteration is the score
method of the estimator. It is possible to change this by using the
scoring parameter:
从DecisionTreeClassifier documentation: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.
不要被“平均准确度”所迷惑,这只是计算准确度的常规方法。按照source的链接进行操作:from .metrics import accuracy_score
return accuracy_score(y, self.predict(X), sample_weight=sample_weight)
现在是metrics.accuracy_score的source
^{pr2}$
def _weighted_sum(sample_score, sample_weight, normalize=False):
if normalize:
return np.average(sample_score, weights=sample_weight)
elif sample_weight is not None:
return np.dot(sample_score, sample_weight)
else:
return sample_score.sum()
注意:对于accuracy_score,normalize参数默认为True,因此它只返回布尔numpy数组的np.average,因此它只是正确预测的平均数。在