我正在尝试在google cloud ai平台上创建一个版本,但它找不到impute模块
No module named 'sklearn.impute._base; 'sklearn.impute' is not a package

框架版本是sklearn 0.20.4,最后我检查了一下文档0.20.4中有sklearn.impute应用程序接口。
第1785页https://scikit-learn.org/0.20//_downloads/scikit-learn-docs.pdf
整个sklearn包都包含在ai平台中了吗?有没有变通的办法(我真的不想写一个自定义的输入器),或者我用错了ai平台?
发布于 2020-02-02 14:59:20
最新的运行时版本1.15和旧版本中包含scikit-learn 0.20.4。
来自scikit学习文档:https://scikit-learn.org/stable/modules/generated/sklearn.impute.SimpleImputer.html该函数包含在0.20.4中:
我在本地尝试了Python3.5/3.7,调用该方法效果很好:
...
scikit-learn==0.20.4
scipy==1.4.1
six==1.14.0
tensorboard==1.15.0
tensorflow==1.15.2
tensorflow-estimator==1.15.1
termcolor==1.1.0
Werkzeug==0.16.1
wrapt==1.11.2
...
>>> import numpy as np
>>> from sklearn.impute import SimpleImputer
>>> imp_mean = SimpleImputer(missing_values=np.nan, strategy='mean')
>>> imp_mean.fit([[7, 2, 3], [4, np.nan, 6], [10, 5, 9]])
SimpleImputer(copy=True, fill_value=None, missing_values=nan, strategy='mean',
verbose=0)AI Platform Training and Prediction API使用的默认AI Platform Training运行时版本是1.0版。如果未指定运行时版本,AI Platform Training将使用1.0版。
确保在启动作业时设置了正确的运行时版本:
gcloud ai-platform jobs submit training my_job \
--module-name trainer.task \
--job-dir gs://my/training/job/directory \
--package-path /path/to/my/project/trainer \
--region us-central1
--runtime-version 1.15问:你能分享一下你是如何启动作业和设置运行时版本的吗?
发布于 2020-01-28 02:43:21
我过去也遇到过类似的问题。sklearn包包含在AI平台中,但是,如果您使用与AI平台使用的版本不同的版本来训练模型,则需要返回并使用与AI平台的运行时所使用的版本相同的scikit-learn版本来重新训练模型。
希望这能有所帮助!
https://stackoverflow.com/questions/59917440
复制相似问题