简体   繁体   English

如何通过将元组更改为...来完成对元组的 fit_transform,或者能够对数据完成 fit_transform?

[英]how to complete fit_transform on tuple, or be able to complete a fit_transform on the data, by changing tuple to...?

So first question: I read up on this error and it says it is type: tuple, so I am confused what the error is and what to do to fix it.所以第一个问题:我阅读了这个错误,它说它是类型:元组,所以我很困惑错误是什么以及如何修复它。 A beginner, so please provide detailed suggestions.初学者,所以请提供详细的建议。 tried changing (df_x) to [df_x], as per instructions in similar question, without success.根据类似问题中的说明,尝试将 (df_x) 更改为 [df_x],但没有成功。

cv2=TfidfVectorizer(sublinear_tf=True,min_df=1),#stop_words='english')
        updated_x2=cv2.fit_transform[df_x]
        fn2=cv2.get_feature_names()
        AttributeError                            Traceback (most recent call last)
        <ipython-input-52-ddf0f04628ff> in <module>
        1 cv2=TfidfVectorizer(sublinear_tf=True,min_df=1),#stop_words='english')
---->   2 updated_x2=cv2.fit_transform[df_x]
        3 fn2=cv2.get_feature_names()

        AttributeError: 'tuple' object has no attribute 'fit_transform'
cv2=TfidfVectorizer(sublinear_tf=True,min_df=1),

creates cv2 as a tuple because of the unintended trailing comma.由于意外的尾随逗号,将cv2创建为tuple If you adjust your comment to precede it, ie如果你调整你的评论在它之前,即

cv2=TfidfVectorizer(sublinear_tf=True,min_df=1)#, stop_words='english')

It should get rid of that error它应该摆脱那个错误

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM