【发布时间】:2019-05-22 18:27:24
【问题描述】:
我必须交付一个机器学习项目,我收到了一个名为 tester.py 的文件。在另一个文件中编写完代码后,我必须运行 tester.py 才能查看结果,但出现错误:TypeError: 'StratifiedShuffleSplit' object is not iterable
我在另一个主题和网站上研究过这个错误,解决方法总是一样的:使用 sklearn.model_selection 导入 GridSearchCV。从一开始我就已经这样做了,但是文件 tester.py 没有运行。
tester.py 中出现问题的部分代码是:
def main():
### load up student's classifier, dataset, and feature_list
clf, dataset, feature_list = load_classifier_and_data()
### Run testing script
test_classifier(clf, dataset, feature_list)
if __name__ == '__main__':
main()
我自己的代码运行良好。
有什么帮助吗?
【问题讨论】:
-
显示完整的堆栈跟踪和使用 StratifiedShuffleSplit 的实际代码。