Scikit-learn 参数 oob_score、oob_score_、oob_prediction_
Scikit-learn parameters oob_score, oob_score_, oob_prediction_
我很难找出 oob_score_ 对 scikit-learn 中的随机森林回归器意味着什么。在文档中它说:
oob_score_ : 浮动
使用袋外估计获得的训练数据集的分数。
起初我以为它会 return out-of-bag 实例集上每个实例的分数。但这是由属性给出的:
oob_prediction_ : 形状数组 = [n_samples]
使用训练集的袋外估计计算的预测。
其中 return 是一个数组,其中包含每个实例的预测。然后分析文档上的其他参数,我意识到该方法
score(X, y, sample_weight=None) returns 决定系数 R².
考虑到调用属性 oob_score_ return 是单个浮点值,它代表什么?如果可能的话,我也想知道它是如何计算的。
文档的 link 是 RandomForestRegressor。
它returns正是文档中所说的
oob_score_ : float Score of the training dataset obtained using an out-of-bag estimate.
哪里得分
score(X, y, sample_weight=None) returns the Coefficient of determination R².
和袋外估计是由于装袋程序而未用于训练的样本。
只看一个source,第727-740行
predictions /= n_predictions
self.oob_prediction_ = predictions
if self.n_outputs_ == 1:
self.oob_prediction_ = \
self.oob_prediction_.reshape((n_samples, ))
self.oob_score_ = 0.0
for k in range(self.n_outputs_):
self.oob_score_ += r2_score(y[:, k],
predictions[:, k])
self.oob_score_ /= self.n_outputs_
换句话说,它只是 oob_prediction_
上的 R2 分数
我很难找出 oob_score_ 对 scikit-learn 中的随机森林回归器意味着什么。在文档中它说:
oob_score_ : 浮动 使用袋外估计获得的训练数据集的分数。
起初我以为它会 return out-of-bag 实例集上每个实例的分数。但这是由属性给出的:
oob_prediction_ : 形状数组 = [n_samples] 使用训练集的袋外估计计算的预测。
其中 return 是一个数组,其中包含每个实例的预测。然后分析文档上的其他参数,我意识到该方法 score(X, y, sample_weight=None) returns 决定系数 R².
考虑到调用属性 oob_score_ return 是单个浮点值,它代表什么?如果可能的话,我也想知道它是如何计算的。
文档的 link 是 RandomForestRegressor。
它returns正是文档中所说的
oob_score_ : float Score of the training dataset obtained using an out-of-bag estimate.
哪里得分
score(X, y, sample_weight=None) returns the Coefficient of determination R².
和袋外估计是由于装袋程序而未用于训练的样本。
只看一个source,第727-740行
predictions /= n_predictions
self.oob_prediction_ = predictions
if self.n_outputs_ == 1:
self.oob_prediction_ = \
self.oob_prediction_.reshape((n_samples, ))
self.oob_score_ = 0.0
for k in range(self.n_outputs_):
self.oob_score_ += r2_score(y[:, k],
predictions[:, k])
self.oob_score_ /= self.n_outputs_
换句话说,它只是 oob_prediction_