python - 创建版本失败。检测到错误模型错误:“...没有名为 'sklearn.impute._base' 的模块;'sklearn.impute' 不是包。(错误代码:0)”
问题描述
我正在尝试在 google cloud ai 平台上创建一个版本,但找不到 impute 模块
No module named 'sklearn.impute._base; 'sklearn.impute' is not a package
框架版本是 sklearn 0.20.4,最后我检查了 doc 0.20.4 有 sklearn.impute api。
第 1785 页 https://scikit-learn.org/0.20//_downloads/scikit-learn-docs.pdf
整个sklearn包是否包含在ai平台中?是否有解决方法(真的不想编写自定义输入器)还是我使用的 ai 平台错了?
解决方案
scikit-learn 0.20.4 包含在最新的运行时版本1.15和旧版本中。
来自 scikit-learn 文档:https ://scikit-learn.org/stable/modules/generated/sklearn.impute.SimpleImputer.html 该函数包含在 0.20.4 中:
我在本地尝试使用 Python 3.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
问题:您能分享一下您是如何启动作业并设置运行时版本的吗?
推荐阅读
- c - Does the distance between read and write locations have an effect on cache performance?
- java - 使用 RxJava 对数组进行异步 forEach
- javascript - 如何获得动画下拉菜单?
- mysql - 如何从自动递增的主键切换到保留外键关系的 uuid
- python - 奇怪的日期时间格式 - Python
- c# - 邮递员 - 如何从列表中传递数据
,在内存中,进入 Newman 命令行的 -data 部分 - java - 使用 Homebrew 为 Mac 安装 OpenJDK 8 (subversion 1.8.0.119)?
- background-color - Android - 如何动态更改背景颜色或整个 TabLayout?
- python - PySpark 中的数据框未显示
- python - 从 .npy 文件中提取元素,将它们转换为 PyTorch 张量