X_train, X_test, y_train, y_test = train_test_split(wine_dataset['data'], wine_dataset['target'], random_state = 0)
以上语句在jupytet notebook报错 : TypeError: ‘function’ object is not subscriptable
解决办法:
给wine_dataset[‘data’] 和 wine_dataset[‘target’] 加上括号:
wine_dataset([‘data’]), wine_dataset([‘target’])
像这种问题TypeError: ‘function’ object is not subscriptable
一般都是由于函数没加括号导致的;
解决TypeError: ‘function’ object is not subscriptable错误
本文详细介绍了在使用Python进行数据集划分时遇到的TypeError: ‘function’ object is not subscriptable错误及其解决方案。通常,这个问题发生在尝试访问函数对象的属性时未正确使用括号。通过正确调用函数并传递参数,可以避免此类错误。

3991

被折叠的 条评论
为什么被折叠?



