简体   繁体   English

来自 scikit-learn 的 TransformedTargetRegressor 的分数是否正确?

[英]Is the score from TransformedTargetRegressor of scikit-learn correct?

I made a short Jupyter notebook to go with my question regarding the TransformedTargetRegressor.我制作了一个简短的Jupyter 笔记本来回答我关于 TransformedTargetRegressor 的问题。
I wanted to put a transformer inside a pipeline to play with a parameter grid but the scores didn't match.我想在管道中放置一个变压器来使用参数网格,但分数不匹配。

...
model = linear_model.LinearRegression()
lg_tr = preprocessing.FunctionTransformer(func=np.log, inverse_func=np.exp, check_inverse=True)
y_log = lg_tr.transform(y)
score_0 = model.fit(X, y_log).score(X, y_log)
...
model = compose.TransformedTargetRegressor(func=np.log, inverse_func=np.exp, check_inverse=True,
    regressor=linear_model.LinearRegression())
score_1 = model.fit(X, y).score(X, y)

The score_0 value is correct. score_0值是正确的。 Why is the one from score_1 not?为什么不是来自score_1
I don't have problem with the prediction that works fine, only the score.我对工作正常的预测没有问题,只有分数。
Did I miss something?我错过了什么?
Thank you =)谢谢你=)

Typically, you should be interested on how good your model performs (or scores) when predicting the actual values in their original range or scale.通常,在预测原始范围或尺度中的实际值时,您应该对模型的表现(或得分)感兴趣。 This is however what you are measuring with score_1 and not with score_0 .但是,这是您使用score_1不是score_0测量的score_0

score_0 represents the model's performance when the target variable is in log scale which is in most cases not very useful. score_0表示当目标变量处于对数刻度时模型的性能,这在大多数情况下不是很有用。

score_1 however uses the score method of TransformedTargetRegressor which makes sure the target variable is in its original scale before computing any performance metric.然而, score_1使用TransformedTargetRegressorscore方法,该方法在计算任何性能指标之前确保目标变量处于其原始规模。 Thus, judgements should be made based on score_1 .因此,应根据score_1进行判断。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以将 TransformedTargetRegressor 添加到 scikit-learn 管道中? - Is it possible to add TransformedTargetRegressor into a scikit-learn pipeline? 如何从 scikit-learn 中的 TransformedTargetRegressor 管道中的经过训练的估计器访问属性? - How to access attribute from a trained estimator in TransformedTargetRegressor pipeline in scikit-learn? scikit-learn-explained_variance_score - scikit-learn - explained_variance_score 没有二元分类器的 scikit-learn 中的 auc 分数 - auc score in scikit-learn for no binary classifiers 理解scikit-learn KMeans返回的“得分” - Understanding “score” returned by scikit-learn KMeans RFECV() 在 python scikit-learn 中的得分 - Score of RFECV() in python scikit-learn Scikit-learn:集群评估的 ARI 分数 - Scikit-learn: ARI score for cluster evaluation Scikit-learn:roc_auc_score - Scikit-learn : roc_auc_score 拟合模型上的评分方法与scikit-learn的precision_score有什么区别? - What's the difference between the score method on a fitted model, vs accuracy_score from scikit-learn? 如何将 inverse_transform 用于 Scikit-Learn PowerTransformer() 设置为 GridSearchCV 管道中 TransformedTargetRegressor 中的转换器参数 - How to use inverse_transform for a Scikit-Learn PowerTransformer() set as transformer param in TransformedTargetRegressor in a pipe in GridSearchCV
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM