需要帮助解决错误 NameError: name 'countVectorizer' is not defined in PyCharm我正在尝试从此源https://github.com/chdoig/pytexas2015-ml执行 FEATURE EXTRACTION 代码文件名:1-Feature_extraction.ipynbimport numpy as npimport pandas as pdtrain_data = pd.read_csv('labeledTrainData.tsv',sep='\t')print(train_data)print(train_data.iloc[1].review)test_data = pd.read_csv('testData.tsv',sep = '\t')print(test_data)import matplotlib.pyplot as pltimport seaborn as snstrain_data['review_len'] = train_data.review.apply(len)len_pl = plt.hist(train_data.review_len.values)plt.show(len_pl)#describe negative reviewsprint(train_data[train_data.sentiment==0].describe())print(train_data[train_data.sentiment==1].describe())#inspecting outliersprint(train_data[train_data.review_len==52].review.all())print(train_data[train_data.review_len==13708].review.all())#word exrtactionfrom sklearn.feature_extraction.text import CountVectorizervocab = ['awesome', 'terrible']simple_vectorizer = countVectorizer(vocabulary=vocab)bow = simple_vectorizer.fit_transform(train_data.review).todense()print(bow)错误/警告: C:\Users\hi\PycharmProjects\Practice2\venv\Scripts\python.exe C:/Users/hi/PycharmProjects/Practice2/P1.py C:\Users\hi\PycharmProjects\Practice2\venv\lib \site-packages\sklearn\externals\joblib\externals\cloudpickle\cloudpickle.py:47: DeprecationWarning: 不推荐使用 imp 模块以支持 importlib;请参阅模块文档以了解替代用途 import imp Traceback(最近一次调用最后一次):文件“C:/Users/hi/PycharmProjects/Practice2/P1.py”,第 32 行,在 simple_vectorizer = countVectorizer(vocabulary=vocab) NameError: name 'countVectorizer' 未定义进程以退出代码 1 结束
添加回答
举报
0/150
提交
取消