print("训练集上的准确率:",logistic.score(train_x_std_lda,train_y)) print("测试集上的准确率:",logistic.score(test_x_std_lda,test_y))训练集上的准确率: 0.991935483871 测试集上的准确率: 1.0
第九步:评估模型。 fromsklearn.metricsimportaccuracy_score,confusion_matrix#导入准确度和混合矩阵 print('Accuracy : '+str(accuracy_score(y_test,y_pred)))#准确度 conf_m=confusion_matrix(y_test,y_pred)#得到混合矩阵 print(conf_m) 1. 2. 3. 4. 如下: Accuracy:1.0 [[900] [0100] [0011]]...
plexs.append(lda.perplexity(tf)) scores.append(lda.score(tf)) 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. import matplotlib.pyplot as plt n_t=12#区间最右侧的值。注意:不能大于n_max_topics x=list(range(1,n_t)) plt.plot(x,plexs[1:n_t]) plt.xlabel("number of topics") plt....
['emotion_score'] = '' for i, row in df1.iterrows(): text = row['cut'] # 获取文本数据 s = SnowNLP(text) score = s.sentiments # 将情感得分添加到 DataFrame 中 df1.at[i, 'emotion_score'] = score # 查看 DataFrame print(df1.head()) df1.to_excel('E:/网易云数据评论/最后完成...