我正在做一个项目,将总统辩论推文分为中立、正面和负面。(不是当前的辩论数据集)。我正在训练和使用
Decision trees
,
Decision tree ensemble
和
AdaBoost
我拥有的数据是以
bag-of-words
df_obama
是一个数据框架,包含所有关于奥巴马的推文。
df_Obama = pd.DataFrame.from_csv("../data/Obama_BagOfWords.csv")
df_Obama = df_Obama.reindex(np.random.permutation(df_Obama.index)).reset_index()
dataFeatures = df_Obama[allAttribs_Obama]
targetVar = list(df_Obama['Class'])
splitRatio = 0.9
splitPoint = int(splitRatio*len(dataFeatures))
dataFeatures_train = dataFeatures[:splitPoint]
dataFeatures_test = dataFeatures[splitPoint:]
targetVar_train = targetVar[:splitPoint]
targetVar_test = targetVar[splitPoint:]
clfObj = tree.DecisionTreeClassifier()
clfObj.fit(dataFeatures_train,targetVar_train)
preds = list(clfObj.predict(dataFeatures_test))
accScore = accuracy_score(targetVar_test,preds)
labels = [1,-1,0]
precision = precision_score(targetVar_test,preds,average=None,labels=labels)
recall = recall_score(targetVar_test,preds,average=None,labels=labels)
f1Score = f1_score(targetVar_test,preds,average=None,labels=labels)
print("Overall Acurracy",accScore)
print("precision",precision)
print("recall",recall)
print("f1Score",f1Score)
Overall Acurracy 1.0
precision [ 1. 1. 1.]
recall [ 1. 1. 1.]
f1Score [ 1. 1. 1.]
我就是不明白为什么会这样?指标如此之高有什么原因吗?
我还尝试了不同的列车测试分流比,结果似乎没有什么不同。
注:
以下是数据信息:
df_Obama.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5465 entries, 0 to 5464
Columns: 13078 entries, level_0 to zzzzzzzzzz
dtypes: int64(13078)
memory usage: 545.3 MB
df_Obama.head(3)
0023Washington 08hayabusa 09Its .... 09what 1000000th
0 1 0 1 0
1 0 0 0 0
0 0 0 0 0