使用转换器(estimator)来转换 sklearn.pipeline 中的目标标签 [英] Using a transformer (estimator) to transform the target labels in sklearn.pipeline

查看:60
本文介绍了使用转换器(estimator)来转换 sklearn.pipeline 中的目标标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,可以链接多个估计器,这些估计器实现了转换方法以转换 sklearn.pipeline 中的 X(特征集).但是,我有一个用例,我还想转换目标标签(例如将标签转换为 [1...K] 而不是 [0, K-1],我很乐意将其作为管道中的一个组件来执行). 是否有可能使用 sklearn.pipeline.

I understand that one can chain several estimators that implement the transform method to transform X (the feature set) in sklearn.pipeline. However I have a use case where I would like also transform the target labels (like transform the labels to [1...K] instead of [0, K-1] and I would love to do that as a component in my pipeline. Is it possible to that at all using the sklearn.pipeline.?

推荐答案

不,管道将始终通过 y 不变.在管道外进行转换.

No, pipelines will always pass y through unchanged. Do the transformation outside the pipeline.

(这是 scikit-learn 中的一个已知设计缺陷,但它从来没有足够紧迫地改变或扩展 API.)

(This is a known design flaw in scikit-learn, but it's never been pressing enough to change or extend the API.)

这篇关于使用转换器(estimator)来转换 sklearn.pipeline 中的目标标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆