Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

第二章 PipeLine的示例代码运行出错 #52

Open
vine3401 opened this issue May 4, 2018 · 0 comments
Open

第二章 PipeLine的示例代码运行出错 #52

vine3401 opened this issue May 4, 2018 · 0 comments

Comments

@vine3401
Copy link

vine3401 commented May 4, 2018

关于特征缩放的代码,就是下面这个Pipeline转换流水线

num_attribs = list(housing_num)
cat_attribs = ["ocean_proximity"]

num_pipeline = Pipeline([
    ('selector', DataFrameSelector(num_attribs)),
    ("imputer", Imputer(strategy="median")),
    ("attribs_adder", CombinedAttributesAdder()),
    ("std_scaler", StandardScaler()),
])
cat_pipeline = Pipeline([
    ('selector', DataFrameSelector(cat_attribs)),
    ('label_binarizer', LabelBinarizer()),
])

full_pipeline = FeatureUnion(transformer_list=[
    ("num_pipeline", num_pipeline),
    ("cat_pipeline", cat_pipeline)
])

housing_prepared = full_pipeline.fit_transform(housing)

运行报错如下:TypeError: fit_transform() takes 2 positional arguments but 3 were given,

查了网上资料后发现是版本问题,LabelBinareizerfit_transform函数参数定义改变了:

"""
The pipeline is assuming LabelBinarizer's fit_transform method is defined to take three positional arguments:
"""
def fit_transform(self, x, y)
    ...rest of the code
while it is defined to take only two:

def fit_transform(self, x):
    ...rest of the code

希望能解决一哈,虽然找到了问题,但不知道咋改(新手QAQ)

@PeterHo PeterHo mentioned this issue May 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant