Traceback (most recent call last): File "D:/pycharts程序/基于機器學習的銷售量預測/main/随机森林模型.py", line 137, in <module> rfr.fit(X_train,y_train) File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\ensemble\_forest.py", line 467, in fit for i, t in enumerate(trees) File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\joblib\parallel.py", line 1056, in __call__ self.retrieve() File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\joblib\parallel.py", line 935, in retrieve self._output.extend(job.get(timeout=self.timeout)) File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\multiprocessing\pool.py", line 657, in get raise self._value File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\multiprocessing\pool.py", line 121, in worker result = (True, func(*args, **kwds)) File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\joblib\_parallel_backends.py", line 595, in __call__ return self.func(*args, **kwargs) File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\joblib\parallel.py", line 263, in __call__ for func, args, kwargs in self.items] File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\joblib\parallel.py", line 263, in <listcomp> for func, args, kwargs in self.items] File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\utils\fixes.py", line 216, in __call__ return self.function(*args, **kwargs) File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\ensemble\_forest.py", line 185, in _parallel_build_trees tree.fit(X, y, sample_weight=curr_sample_weight, check_input=False) File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\tree\_classes.py", line 1320, in fit X_idx_sorted=X_idx_sorted, File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\tree\_classes.py", line 356, in fit criterion = CRITERIA_REG[self.criterion](self.n_outputs_, n_samples) KeyError: 'rmse'
时间: 2023-06-15 15:04:11 浏览: 160
tables-3.6.1-cp39-cp39-win_amd64.whl
这个错误发生在 sklearn 的随机森林模型的训练过程中,具体原因是因为你使用了一个不存在的 criterion(评估标准)参数值 'rmse'。随机森林模型只支持以下几种评估标准:
- mse:均方误差
- mae:平均绝对误差
- mape:平均绝对百分比误差
- poisson:泊松回归
请检查你的代码,将 criterion 参数设置为以上几种可用的评估标准之一即可。
阅读全文