鏈哄櫒瀛︿範锛?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

https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.CountVectorizer.html?highlight=sklearn%20feature_extraction%20text%20tfidfvectorizer

sklearn.feature_extraction.text.TfidfVectorizer

https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.TfidfVectorizer.html?highlight=sklearn%20feature_extraction%20text%20tfidfvectorizer#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的主要内容,如果未能解决你的问题,请参考以下文章

Docker 鍨冨溇鍥炴敹鏈哄埗琛ュ厖

鏈哄櫒瀛︿範瀹炴垬-Logistics鍥炲綊

鏈哄櫒瀛︿範瀛︿範绱㈠紩

鏈哄櫒瀛︿範瀹炴垬锛氭敮鎸佸悜閲忔満(涓?

鏈哄櫒瀛︿範鈥斺€斿簲鐢ㄥ満鏅? 绠楁硶搴旂敤鍦烘櫙

鏈哄櫒瀛︿範瀹炴垬锛?锛夛細鏀寔鍚戦噺鏈猴紙涓嬶級