【自用】 sklearn 中的各种分类器

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

### Multinomial Naive Bayes Classifier    
from sklearn.naive_bayes import MultinomialNB

clf = MultinomialNB(alpha=0.01)
clf.fit(train_x, train_y)


### KNN Classifier    
from sklearn.neighbors import KNeighborsClassifier

clf = KNeighborsClassifier()
clf.fit(train_x, train_y)


### Logistic Regression Classifier    
from sklearn.linear_model import LogisticRegression

clf = LogisticRegression(penalty='l2')
clf.fit(train_x, train_y)


### Random Forest Classifier    
from sklearn.ensemble import RandomForestClassifier

clf = RandomForestClassifier(n_estimators=8)
clf.fit(train_x, train_y)


### Decision Tree Classifier    
from sklearn import tree

clf = tree.DecisionTreeClassifier()
clf.fit(train_x, train_y)


### GBDT(Gradient Boosting Decision Tree) Classifier    
from sklearn.ensemble import GradientBoostingClassifier

clf = GradientBoostingClassifier(n_estimators=200)
clf.fit(train_x, train_y)


### SVM Classifier    
from sklearn.svm import SVC

clf = SVC(kernel='rbf', probability=True)
clf.fit(train_x, train_y)

 

    PS:自用的  不做解释                        作者:一个吃货帅锅     

转载于:https://my.oschina.net/kilosnow/blog/1632464

你可能感兴趣的:(人工智能,python,数据结构与算法)