我正在使用 Ubuntu 14.04,python=2.7,numpy=1.10.1,scikit-learn=0.17.1,scipy=0.17.1
,但是在代码的导入部分,IDLE
和 Spyder
(conda=4.1.3,conda-env=2.5.0a0)都出现了 Import Error:
import numpy as np
from sklearn.cross_validation import train_test_split
import csv
import pandas
from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer
from sklearn.tree import DecisionTreeClassifier
from bs4 import BeautifulSoup
import re
from sklearn.multiclass import OneVsRestClassifier
from sklearn.linear_model import SGDClassifier
from sklearn import neighbors
from sklearn.ensemble import RandomForestClassifier
from sklearn import metrics
from sklearn.svm import SVC
from sklearn.naive_bayes import GaussianNB
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis
from sklearn.metrics import accuracy_score
from sklearn.neighbors import KNeighborsClassifier
from sklearn.svm import SVC
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
我遇到了以下错误:
然而,在终端(Python)中,我尝试按照以下方式导入:LinearDiscriminantAnalysis:导入错误:没有找到名为discriminant_analysis的模块
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
没有任何错误?!我不知道原因是什么,也不知道该怎么修复它。