鏈哄櫒瀛︿範锛?3-鍨冨溇閭欢鍒嗙被2
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鏈哄櫒瀛︿範锛?3-鍨冨溇閭欢鍒嗙被2相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e9%82%ae%e4%bb%b6' title='閭欢'>閭欢 cto get ati epo 瑙傚療 鏈哄櫒 extra text
1.璇诲彇
2.鏁版嵁棰勫鐞?/h1>
3.鏁版嵁鍒掑垎—璁粌闆嗗拰娴嬭瘯闆嗘暟鎹垝鍒?/h1>
from sklearn.model_selection import train_test_split
x_train,x_test, y_train, y_test = train_test_split(data, target, test_size=0.2, random_state=0, stratify=y_train)
4.鏂囨湰鐗瑰緛鎻愬彇
sklearn.feature_extraction.text.CountVectorizer
sklearn.feature_extraction.text.TfidfVectorizer
from sklearn.feature_extraction.text import TfidfVectorizer
tfidf2 = TfidfVectorizer()
瑙傚療閭欢涓庡悜閲忕殑鍏崇郴
鍚戦噺杩樺師涓洪偖浠?/p>
4.妯″瀷閫夋嫨
from sklearn.naive_bayes import GaussianNB
from sklearn.naive_bayes import MultinomialNB
璇存槑涓轰粈涔堥€夋嫨杩欎釜妯″瀷锛?/p>
5.妯″瀷璇勪环锛氭贩娣嗙煩闃碉紝鍒嗙被鎶ュ憡
from sklearn.metrics import confusion_matrix
confusion_matrix = confusion_matrix(y_test, y_predict)
璇存槑娣锋穯鐭╅樀鐨勫惈涔?/p>
from sklearn.metrics import classification_report
璇存槑鍑嗙‘鐜囥€佺簿纭巼銆佸彫鍥炵巼銆丗鍊煎垎鍒唬琛ㄧ殑鎰忎箟
6.姣旇緝涓庢€荤粨
濡傛灉鐢–ountVectorizer杩涜鏂囨湰鐗瑰緛鐢熸垚锛屼笌TfidfVectorizer鐩告瘮锛屾晥鏋滃浣曪紵
以上是关于鏈哄櫒瀛︿範锛?3-鍨冨溇閭欢鍒嗙被2的主要内容,如果未能解决你的问题,请参考以下文章