2016-08-23 71 views
11

我有一个管道scikit学习使用自定义变压器我这样定义如下:Sklearn管道 - 如何继承自定义的变压器(未估计)get_params

class MyPipelineTransformer(TransformerMixin): 

定义功能

__init__, fit() and transform() 

然而,当我使用内部RandomizedSearchCV管道,我得到以下错误:

'MyPipelineTransformer' object has no attribute 'get_params'

我在线阅读过(例如下面的链接)

(Python - sklearn) How to pass parameters to the customize ModelTransformer class by gridsearchcv

http://scikit-learn.org/stable/auto_examples/hetero_feature_union.html

,我可以从BaseEstimator继承,而不是我当前的代码只是从TransformerMixin继承,获得 'get_params'。但我的变压器不是估算器。从BaseEstimator继承非估算器有什么不好吗?或者是推荐的方式来获取管道中任何变压器(估计器或不是)的get_params?

+1

我upvoted,我不知道你的问题的答案,但你应该使用UpperCamelCase命名类。请,只为我做。这让我疯狂。 –

+0

谢谢,Juanpa。你是对的。相应编辑https://www.python.org/dev/peps/pep-0008/#class-names –

+0

@MaxPower您的MyPipelineTransformer是否在管道中封装了几个步骤? – nanounanue

回答