本文整理汇总了Python中sklearn.naive_bayes.GaussianNB.kneighbors方法的典型用法代码示例。如果您正苦于以下问题:Python GaussianNB.kneighbors方法的具体用法?Python GaussianNB.kneighbors怎么用?Python GaussianNB.kneighbors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.naive_bayes.GaussianNB
的用法示例。
在下文中一共展示了GaussianNB.kneighbors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: accuracy_score
# 需要导入模块: from sklearn.naive_bayes import GaussianNB [as 别名]
# 或者: from sklearn.naive_bayes.GaussianNB import kneighbors [as 别名]
accuracy = accuracy_score(labels_test, pred)
print accuracy
####### K Nearest Neighbors #####
### #
### #
######################################################################################################
from sklearn.neighbors import KNeighborsClassifier
t0 = time()
clf = KNeighborsClassifier(n_neighbors=1) # default value is 2
# clf = NearestNeighbors(n_neighbors=2, algorithm='ball_tree').fit(features_train)
clf.fit(features_train, labels_train)
print "training time:", round(time()-t0, 3), "s"
distances, indices = clf.kneighbors(features_train)
t1 = time()
pred = clf.predict(features_test)
print "predict time:", round(time()-t1, 3), "s"
# # Method 1
from sklearn.metrics import accuracy_score
accuracy = accuracy_score(labels_test, pred)
print accuracy
############ AdaBoost ###########
### #
### #
######################################################################################################
from sklearn.cross_validation import cross_val_score