本文整理汇总了Python中sklearn.naive_bayes.MultinomialNB.fit_semi方法的典型用法代码示例。如果您正苦于以下问题:Python MultinomialNB.fit_semi方法的具体用法?Python MultinomialNB.fit_semi怎么用?Python MultinomialNB.fit_semi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.naive_bayes.MultinomialNB
的用法示例。
在下文中一共展示了MultinomialNB.fit_semi方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _test_semi
# 需要导入模块: from sklearn.naive_bayes import MultinomialNB [as 别名]
# 或者: from sklearn.naive_bayes.MultinomialNB import fit_semi [as 别名]
def _test_semi(NaiveBayes):
clf = MultinomialNB(alpha=.01)
clf.fit(X_train, y_train)
# clf.fit(X_train[:n], Y_train[:n])
pred = clf.predict(X_test)
f1_score = metrics.f1_score(y_test, pred)
print "Supervised Learning - scikits-learn 0.10"
# print "Accuracy: %d/%d" % (np.sum(pred == y_test), len(y_test))
accuracy = float( np.sum(pred == y_test) ) / float(len(y_test))
print "Accuracy: %0.4f" % accuracy
print "F1: %0.4f" % f1_score
clf = NaiveBayes()
clf.fit(X_train, y_train)
# clf.fit(X_train[:n], Y_train[:n])
pred = clf.predict(X_test)
f1_score = metrics.f1_score(y_test, pred)
print "Supervised Learning"
# print "Accuracy: %d/%d" % (np.sum(pred == y_test), len(y_test))
accuracy = float( np.sum(pred == y_test) ) / float(len(y_test))
print "Accuracy: %0.4f" % accuracy
print "F1: %0.4f" % f1_score
clf = NaiveBayes()
clf.fit_semi(X_train, Y_train, X_unlabel)
# clf.fit_semi(X_train[:n], Y_train[:n], X_train[n:])
pred = clf.predict(X_test)
f1_score = metrics.f1_score(y_test, pred)
accuracy = float( np.sum(pred == y_test) ) / float(len(y_test))
print "Semi-Supervised Learning"
print "Accuracy: %0.4f" % accuracy
print "F1: %0.4f" % f1_score
print "-----"