本文整理汇总了Python中sklearn.naive_bayes.GaussianNB.class_prior_方法的典型用法代码示例。如果您正苦于以下问题:Python GaussianNB.class_prior_方法的具体用法?Python GaussianNB.class_prior_怎么用?Python GaussianNB.class_prior_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.naive_bayes.GaussianNB
的用法示例。
在下文中一共展示了GaussianNB.class_prior_方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from sklearn.naive_bayes import GaussianNB [as 别名]
# 或者: from sklearn.naive_bayes.GaussianNB import class_prior_ [as 别名]
tailles = np.concatenate( (taille_h,taille_f) )
poids = np.concatenate( (poids_h,poids_f) )
data = np.column_stack( (tailles,poids) )
gnb.fit(data, classes)
#######
# MAP
#######
y_pred=gnb.predict(data)
p_err, err=computeNaif(y_pred,classes)
print("Prédiction MAP", gnb.class_prior_ , "% d'erreurs :" , p_err*100, "soit", err ,"/", len(y_pred))
#######
# ML
#######
gnb.class_prior_ = [0.48,0.52]
y_pred=gnb.predict(data)
p_err, err=computeNaif(y_pred,classes)
print("Prédiction ML", gnb.class_prior_ , "% d'erreurs :" , p_err*100, "soit", err ,"/", len(y_pred))
#######
# Naif
#######
gnb.class_prior_ = [0.5,0.5]
y_pred=gnb.predict(data)
p_err, err=computeNaif(y_pred,classes)
print("Prédiction Naif", gnb.class_prior_ , "% d'erreurs :" , p_err*100, "soit", err ,"/", len(y_pred))
#######
# Twice
#######
示例2: missing
# 需要导入模块: from sklearn.naive_bayes import GaussianNB [as 别名]
# 或者: from sklearn.naive_bayes.GaussianNB import class_prior_ [as 别名]
# replace missing (-1) values for distance with max int size
imp = Imputer(-1)
train_feats = imp.fit_transform(train_feats)
# train_feats[train_feats == -1] = sys.maxsize
print_stars()
print('Multinomial Naive Bayes')
mnb = MultinomialNB(class_prior=[0.9, 0.1])
_, _, _, mnb_probs = train_test_print(
mnb, train_feats, test_feats, train_mask, test_mask)
print_stars()
print('Gaussian Naive Bayes')
gnb = GaussianNB()
gnb.class_prior_ = [0.9, 0.1]
_, _, _, gnb_probs = train_test_print(
gnb, train_feats, test_feats, train_mask, test_mask)
print_stars()
print('Naive Bayes with Square Kernel')
gnb2 = GaussianNB()
gnb2.class_prior_ = [0.9, 0.1]
test_prods = pairwise_products(test_feats)
train_prods = pairwise_products(train_feats)
_, _, _, gnb2_probs = train_test_print(
gnb2, train_prods, test_prods, train_mask, test_mask)
print_stars()
print('K-Nearest Neighbors, k = 25')
knn = KNeighborsClassifier(n_neighbors=25, weights='distance')