python - RuntimeError : The reset parameter is False but there is no n_features_in_ attribute. 是否安装了这个估算器?

标签 python flask scikit-learn pickle

我正在使用 pickle 保存 sklearn.impute.SimpleImputer 对象。输入器适合

imputer = SimpleImputer(missing_values = np.nan, strategy = 'mean')
imputer = imputer.fit(train)
然后我用
pickle.dump(imputer,open('imputer.pkl','wb'))
并使用在 flask 应用程序中加载模型
imputer = pickle.load(open('imputer.pkl','rb'))
如果我检查 imputer.statistics_ ,我可以成功地看到应该估算的值。然而,当我跑
imputer.transform(test)
在我的 Flask 应用程序中使用加载了 pickle 的输入器,我收到以下错误:
“重置参数为 False 但没有”
运行时错误:重置参数为 False 但没有 n_features_in_ 属性。这个估计器安装了吗?
我正在使用 sklearn 0.23.1 版来拟合输入器并转换数据。有没有人对此有任何见解?请让我知道我可以提供哪些其他信息。

最佳答案

将 sklearn 版本恢复到 0.22.2.post1 可以解决您的问题:

pip install scikit-learn==0.22.2.post1
它对我有用。

关于python - RuntimeError : The reset parameter is False but there is no n_features_in_ attribute. 是否安装了这个估算器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63328412/

相关文章:

python - 内部函数未形成闭包

python - 在 Amazon EC2 集群上使用 python scikit-learn 库执行网格搜索

python - 索引错误 : too many indices

python - Django 只是按日期对 ListView 进行排序

python - TKinter tkFileDialog.askopenfilename 总是在其他窗口后面

python - 打印出加入 flask 的结果

python - Flask-sqlalchemy : sqlalchemy. exc.InvalidRequestError

python - sqlalchemy.exc.ResourceClosedError : This Connection is closed error

scikit-learn - 在 scikit-learn 中进行详尽的特征选择?

python - 如何确保子进程不会在父进程终止时终止?