首页 > 解决方案 > /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 部分,但对我来说似乎没问题。

标签: djangopython-3.xattributeerror

解决方案


推荐阅读