1、高斯朴素贝叶斯 (GaussianNB)
from sklearn import datasets iris = datasets.load_iris() from sklearn.naive_bayes import GaussianNB gnb = GaussianNB() y_pred = gnb.fit(iris.data, iris.target).predict(iris.data) print("Number of mislabeled points out of a total %d points : %d" % (iris.data.shape[0],(iris.target != y_pred).sum()))
2、多项式朴素贝叶斯 (MultinomialNB/MNB)
import numpy as np X = np.random.randint(50, size=(1000, 100)) y = np.random.randint(6, size=(1000)) from sklearn.naive_bayes import MultinomialNB clf = MultinomialNB() clf.fit(X, y) print(clf.predict(X[2:3]))
3. 决策树
决策树作为十大经典算法之一,能够很好的处理多分类问题。
决策树的sklearn接口:
class sklearn.tree.DecisionTreeClassifier(criterion=’gini’, splitter=’best’, max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=None, random_state=None, max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, class_weight=None, presort=False)
好啦,以上就是关于sklearn里面的算法使用了哦~大家如果想了解机器人学习的可以多多看下哦~如果大家还想了解更多的机器人学习知识,可以到python学习网上下载了解。