wskrdd
wskrdd
2019-04-04 19:24

报错ImportError: cannot import name 'BaseEstimator'

  • 机器学习

有遇到这个问题的嘛

图片说明

貌似是sklearn库的问题,我卸了numpy scipy scikt-learn又重装也没得用
网上查不到这个报错”ImportError: cannot import name 'BaseEstimator'“

代码:
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split

def datasets_demo():

#获取并打印数据集
iris = load_iris()
print("鸢尾花数据集:\n", iris)
print("查看数据集描述:\n", iris["DESCR"])
print("查看特征值名字:\n", iris.feature_names)
print("查看特征值名字:\n", iris.data, iris.data.shape)


x_train,x_text,y_train,y_text=train_test_split(iris.data,iris.target,text_size=0.2,random_state=22)
prinit("训练集特征值:\n",x_train,x_train.shape)

报错:
D:\python\python.exe "F:/Administrator/python/begin/day1/machine learning.py"
Traceback (most recent call last):
File "F:/Administrator/python/begin/day1/machine learning.py", line 1, in
from sklearn.datasets import load_iris
File "D:\python\lib\site-packages\sklearn__init__.py", line 64, in
from .base import clone
File "D:\python\lib\site-packages\sklearn\base.py", line 6, in
import copy
File "F:\Administrator\python\begin\day1\copy.py", line 1, in
from sklearn.datasets import load_iris
File "D:\python\lib\site-packages\sklearn\datasets__init__.py", line 23, in
from .twenty_newsgroups import fetch_20newsgroups
File "D:\python\lib\site-packages\sklearn\datasets\twenty_newsgroups.py", line 44, in
from ..feature_extraction.text import CountVectorizer
File "D:\python\lib\site-packages\sklearn\feature_extraction__init__.py", line 7, in
from .dict_vectorizer import DictVectorizer
File "D:\python\lib\site-packages\sklearn\feature_extraction\dict_vectorizer.py", line 11, in
from ..base import BaseEstimator, TransformerMixin
ImportError: cannot import name 'BaseEstimator'

进程已结束,退出代码1

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答