基本理论
鉴于网上有很多好的文章理论部分我就不写了,放出下面的参考。可以先看理论。再看代码了解细节。
详细的理论可参考博文;
具体的sklearn使用方式和调参可参考博文
思维导图
Goodnotes
python 实现
import numpy as np
class Bayes(object):
def __init__(self, model = "multinomial",alpha = 1, log = False):
"""
:param model: "multinomial" : Naive Bayes classifier for multinomial models
"gaussian" :Naive Bayes classifier for gaussian model
"bernoulli" : Naive Bayes classifier for bernoulli model
:param alpha: smoothing
if alpha = 0 is no smoothing,
if 0 < alpha < 1 is Lidstone smoothing
if alpha = 1 is Laplace smoothing
:param log: is True
x1 * x2 * x3 to log(x1 * x2 * x3)
"""
se