我正在尝试运行以下代码:
# Gaussian Naive Bayes
from sklearn import datasets
from sklearn import metrics
from sklearn.naive_bayes import GaussianNB
# load the iris datasets
dataset = datasets.load_iris()
# fit a Naive Bayes model to the data
model = GaussianNB()
model.fit(dataset.data, dataset.target)
print(model)
# make predictions
expected = dataset.target
predicted = model.predict(dataset.data)
# summarize the fit of the model
print(metrics.classification_report(expected, predicted))
print(metrics.confusion_matrix(expected, predicted))
我安装了所有必备模块,如numpy,scipy,scikit-learn。
当我运行代码时,显示的错误是:
追踪(最近一次通话):
文件“C:/Users/user/PycharmProjects/sentiment-analysis/ldaex.py”,第4行,中
来自sklearn导入数据集
文件“C:\ Python27 \ lib \ site-packages \ sklearn__init __。py”,第57行,in
来自.base导入克隆
文件“C:\ Python27 \ lib \ site-packages \ sklearn \ base.py”,第9行,in
从scipy导入稀疏
文件“C:\ Python27 \ lib \ site-packages \ scipy__init __。py”,第131行,in
引发ImportError(“需要numpy openblaspy flavor。”)
ImportError:需要numpy openblaspy flavor。
任何人都可以让我知道模块中的问题???
此外,当我尝试运行以下程序时,会显示相同的错误集:
from sklearn.datasets import fetch_20newsgroups
categories = ['alt.atheism', 'soc.religion.christian','comp.graphics',
'sci.med']
twenty_train = fetch_20newsgroups(subset='train',categories=categories,
shuffle=True, random_state=42)
print twenty_train.target_names