本文整理汇总了Python中sklearn.naive_bayes.MultinomialNB.alpha方法的典型用法代码示例。如果您正苦于以下问题:Python MultinomialNB.alpha方法的具体用法?Python MultinomialNB.alpha怎么用?Python MultinomialNB.alpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.naive_bayes.MultinomialNB
的用法示例。
在下文中一共展示了MultinomialNB.alpha方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MultinomialNB
# 需要导入模块: from sklearn.naive_bayes import MultinomialNB [as 别名]
# 或者: from sklearn.naive_bayes.MultinomialNB import alpha [as 别名]
print "Hstack fini"
X = pipeline.fit_transform(df_train)
X_test = pipeline.transform(df_test)
# print X.shape
# TRAINING
clf_svm = svm.LinearSVC(penalty='l2', loss='squared_hinge', dual=True, tol=0.0001, C=0.5, multi_class='ovr', fit_intercept=True, intercept_scaling=1, class_weight=None, verbose=0, random_state=None, max_iter=1000)
clf_nb = MultinomialNB(alpha=0.04, fit_prior=True, class_prior=None)
#clf_svm = neighbors.KNeighborsClassifier(1)
clf_svm.C = 0.3
clf_nb.alpha = 0.04
l_svm_score = []
l_nb_score = []
l_blend_score = []
alpha = 1.
beta = 20.
#sss = StratifiedShuffleSplit(Y, 5, test_size=0.2, random_state=0)
sss = KFold(len(Y), n_folds=5, shuffle=True)
kbest = SelectKBest(chi2, k=300000)
for train_idx, val_idx in sss:
x_train, y_train, x_val, y_val = X[train_idx], Y[train_idx], X[val_idx], Y[val_idx]
x_train = kbest.fit_transform(x_train, y_train)
x_val = kbest.transform(x_val)