【发布时间】:2019-03-11 19:08:26
【问题描述】:
我有一个回归问题,我正在交叉验证结果并评估性能。我事先知道基本事实不能小于零。因此,我想在将预测输入分数指标之前截取预测,以将预测剪裁为零。我认为使用 make_scorer 函数会很有用。是否有可能在交叉验证之后以某种方式对预测进行后处理,但在对其应用评估指标之前?
from sklearn.metrics import mean_squared_error, r2_score, make_scorer
from sklearn.model_selection import cross_validate
# X = Stacked feature vectors
# y = ground truth vector
# regr = some regression estimator
#### How to indicate that the predictions need post-processing
#### before applying the score function???
scoring = {'r2': make_scorer(r2_score),
'neg_mse': make_scorer(mean_squared_error)}
scores = cross_validate(regr, X, y, scoring=scoring, cv=10)
PS:我知道有约束估计器,但我想看看像这样的启发式方法会如何执行。
【问题讨论】:
标签: python scikit-learn cross-validation