django - /pre_pred/ 处的 AttributeError
问题描述
我已经安装了所有要求并成功运行本地服务器,但是当我尝试运行这个4th_umpire 的预测部分时(使用随机森林算法项目的板球比赛预测器,我收到以下错误:-
在这里,我将展示错误图像中提到的代码的错误部分。
def _transform(self, X, handle_unknown='error'):
X_list, n_samples, n_features = self._check_X(X)
X_int = np.zeros((n_samples, n_features), dtype=np.int)
X_mask = np.ones((n_samples, n_features), dtype=np.bool)
if n_features != len(self.categories_):
raise ValueError(
"The number of features in X is different to the number of "
"features of the fitted data. The fitted data had {} features "
"and the X has {} features."
.format(len(self.categories_,), n_features)
)
例外行是if n_features != len(self.categories_):虽然我已经检查了 OneHotEncoder 部分,但对我来说似乎没问题。
解决方案
推荐阅读
- redux - 无法调用 reactReduxFirebase() - TypeError: Object is not a function
- html - 不可选择的菜单项的事件处理程序
- c# - SecureString 的长度在发送到 webapi 控制器时为 0
- python - 将图像上传到python中的文件夹
- iis - 将 IIS 10 中的所有流量重定向到另一个站点
- c++ - 为什么我不能使用旧引用创建移动构造函数?
- azure-data-explorer - Kusto 提取字符串之间的文本
- docker - docker-compose 中的格式化文件路径
- node.js - 从 lambda 调用 lambda 实例并等待最长的完成
- r - 缺少数据框的行