决策树遇到sklearn.exceptions.NotFittedError: XXX instance is not fitted yet. Call \'fit\' with appropriate arguments before using this method.的解决方案

C:\Python36\python36.exe "E:/python_project/ImoocDataAnalysisMiningModeling/第6章 挖掘建模/6-4~6-5 分类-朴素贝叶斯~分类-决策树.py" C:\Python36\lib\site-packages\sklearn\utils\validation.py:595: DataConversionWarning: Data with input dtype int64 was converted to float64 by MinMaxScaler. warnings.warn(msg, DataConversionWarning) C:\Python36\lib\site-packages\sklearn\utils\validation.py:595: DataConversionWarning: Data with input dtype int64 was converted to float64 by MinMaxScaler. warnings.warn(msg, DataConversionWarning) C:\Python36\lib\site-packages\sklearn\utils\validation.py:595: DataConversionWarning: Data with input dtype int64 was converted to float64 by MinMaxScaler. warnings.warn(msg, DataConversionWarning) C:\Python36\lib\site-packages\sklearn\utils\validation.py:595: DataConversionWarning: Data with input dtype int64 was converted to float64 by MinMaxScaler. warnings.warn(msg, DataConversionWarning) 8999 3000 3000 0 Traceback (most recent call last): KNN ACC: 0.9337704189354372 KNN REC: 0.8670795616960457 File "E:/python_project/ImoocDataAnalysisMiningModeling/第6章 挖掘建模/6-4~6-5 分类-朴素贝叶斯~分类-决策树.py", line 130, in <module> KNN F1 0.8593012275731823 main() File "E:/python_project/ImoocDataAnalysisMiningModeling/第6章 挖掘建模/6-4~6-5 分类-朴素贝叶斯~分类-决策树.py", line 124, in main hr_modeling(features, labels) File "E:/python_project/ImoocDataAnalysisMiningModeling/第6章 挖掘建模/6-4~6-5 分类-朴素贝叶斯~分类-决策树.py", line 116, in hr_modeling filled=True, rounded=True, special_characters=True) File "C:\Python36\lib\site-packages\sklearn\tree\export.py", line 396, in export_graphviz check_is_fitted(decision_tree, \'tree_\') File "C:\Python36\lib\site-packages\sklearn\utils\validation.py", line 951, in check_is_fitted raise NotFittedError(msg % {\'name\': type(estimator).__name__}) sklearn.exceptions.NotFittedError: This KNeighborsClassifier instance is not fitted yet. Call \'fit\' with appropriate arguments before using this method. Process finished with exit code 1

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzsgwd.html