本文整理汇总了Python中sklearn.naive_bayes.MultinomialNB.scorepredict方法的典型用法代码示例。如果您正苦于以下问题:Python MultinomialNB.scorepredict方法的具体用法?Python MultinomialNB.scorepredict怎么用?Python MultinomialNB.scorepredict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.naive_bayes.MultinomialNB
的用法示例。
在下文中一共展示了MultinomialNB.scorepredict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MultinomialNB
# 需要导入模块: from sklearn.naive_bayes import MultinomialNB [as 别名]
# 或者: from sklearn.naive_bayes.MultinomialNB import scorepredict [as 别名]
from sklearn.naive_bayes import MultinomialNB
X_train, X_test, y_train, y_test = cross_validation.train_test_split(a1 ,labelp, test_size=0.2, random_state=0)
clf = MultinomialNB().fit(X_train, y_train[:,0])
clf_score=clf.score(X_test, y_test)
from sklearn.naive_bayes import BernoulliNB
X_train, X_test, y_train, y_test = cross_validation.train_test_split(Xp ,labelp, test_size=0.2, random_state=0)
clf = BernoulliNB().fit(X_train, y_train[:,0])
clf_score=clf.score(X_test, y_test)
##############################33NearestCentroid
from sklearn.neighbors.nearest_centroid import NearestCentroid
clf = NearestCentroid().fit(X_train, y_train[:,0])
clf_score=clf.score(X_test, y_test)
y_new=clf.scorepredict(X_test)
######################################################################embeding plot
similarities = euclidean_distances(X_train)
scipy.io.savemat('C:\\Users\\xp\\Desktop\\Project @ BD\\similarities(log-coe).mat', mdict={'similarities':similarities})
mds = manifold.MDS(n_components=2, max_iter=500,eps=1e-6, n_jobs=1,dissimilarity=precomputed1)
pos = mds.fit(similarities).embedding_
scipy.io.savemat('C:\\Users\\xp\\Desktop\\Project @ BD\\pos(log-coe).mat', mdict={'pos':pos})
plt.scatter(x=pos[:,0].T,y=pos[:,1].T, c=y_new)
pos2 = mds.fit(similarities,y_test).embedding_