原型

class sklearn.naive_bayes.MultinomialNB(alpha=1.0fit_prior=Trueclass_prior=None)

参数

Parameters:

alpha : float, optional (default=1.0)

Additive (Laplace/Lidstone) smoothing parameter (0 for no smoothing).

fit_prior : boolean, optional (default=True)

Whether to learn class prior probabilities or not. If false, a uniform prior will be used.

class_prior : array-like, size (n_classes,), optional (default=None)

Prior probabilities of the classes. If specified the priors are not adjusted according to the data.

alpha的说明——

The parameters  is estimated by a smoothed version of maximum likelihood, i.e. relative frequency counting:

where  is the number of times feature  appears in a sample of class  in the training set , and  is the total count of all features for class .

The smoothing priors  accounts for features not present in the learning samples and prevents zero probabilities in further computations. Setting  is called Laplace smoothing, while  is called Lidstone smoothing.

示例

>>> import numpy as np
>>> X = np.random.randint(5, size=(6, 100))
>>> y = np.array([1, 2, 3, 4, 5, 6])
>>> from sklearn.naive_bayes import MultinomialNB
>>> clf = MultinomialNB()
>>> clf.fit(X, y)
MultinomialNB(alpha=1.0, class_prior=None, fit_prior=True)
>>> print(clf.predict(X[2:3]))

  

sklearn-MultinomialNB朴素贝叶斯分类器的更多相关文章

  1. 第十三次作业——回归模型与房价预测&第十一次作业——sklearn中朴素贝叶斯模型及其应用&第七次作业——numpy统计分布显示

    第十三次作业——回归模型与房价预测 1. 导入boston房价数据集 2. 一元线性回归模型,建立一个变量与房价之间的预测模型,并图形化显示. 3. 多元线性回归模型,建立13个变量与房价之间的预测模 ...

  2. Naive Bayes Classifier 朴素贝叶斯分类器

    贝叶斯分类器的分类 根据实际处理的数据类型, 可以分为离散型贝叶斯分类器和连续型贝叶斯分类器, 这两种类型的分类器, 使用的计算方式是不一样的. 贝叶斯公式 首先看一下贝叶斯公式 $ P\left ( ...

  3. sklearn.naive_bayes中几种朴素贝叶斯分类器

    区别: 几种朴素贝叶斯分类器的区别在于对于分布的假设,即假设满足的形式. 一.高斯NB 导入 from sklearn.naive_bayes import GaussianNB 假设特征的似然函数满 ...

  4. 朴素贝叶斯分类器Naive Bayes

    优点Naive Bayes classifiers tend to perform especially well in one of the following situations: When t ...

  5. NLP系列(4)_朴素贝叶斯实战与进阶

    作者: 寒小阳 && 龙心尘 时间:2016年2月. 出处:http://blog.csdn.net/han_xiaoyang/article/details/50629608 htt ...

  6. [机器学习] 分类 --- Naive Bayes(朴素贝叶斯)

    Naive Bayes-朴素贝叶斯 Bayes' theorem(贝叶斯法则) 在概率论和统计学中,Bayes' theorem(贝叶斯法则)根据事件的先验知识描述事件的概率.贝叶斯法则表达式如下所示 ...

  7. NLP系列(4)_朴素贝叶斯实战与进阶(转)

    http://blog.csdn.net/han_xiaoyang/article/details/50629608 作者: 寒小阳 && 龙心尘 时间:2016年2月. 出处:htt ...

  8. Python机器学习算法 — 朴素贝叶斯算法(Naive Bayes)

    朴素贝叶斯算法 -- 简介 朴素贝叶斯法是基于贝叶斯定理与特征条件独立假设的分类方法.最为广泛的两种分类模型是决策树模型(Decision Tree Model)和朴素贝叶斯模型(Naive Baye ...

  9. 机器学习朴素贝叶斯 SVC对新闻文本进行分类

    朴素贝叶斯分类器模型(Naive Bayles) Model basic introduction: 朴素贝叶斯分类器是通过数学家贝叶斯的贝叶斯理论构造的,下面先简单介绍贝叶斯的几个公式: 先验概率: ...

随机推荐

  1. 负margin

    负margin理论: 何谓参考线?参考线就是 margin移动的基准点,此基准点相对于box(自身)是静止的.而margin的数值,就是box相对于参考线的位移量. 一个完整的margin属性是这么写 ...

  2. Android_ndk_jni_hello-jni_hacking

    /*************************************************************************** * Android_ndk_jni_hello ...

  3. linux-performance

    1. top 2. cat /proc/meminfo nvidia@tegra-ubuntu:~/zrj/laneseg_TRT$ cat /proc/meminfo MemTotal: kB Me ...

  4. opencv-python教程学习系列12-图像阈值

    前言 opencv-python教程学习系列记录学习python-opencv过程的点滴,本文主要介绍图像阈值/二值化,坚持学习,共同进步. 系列教程参照OpenCV-Python中文教程: 系统环境 ...

  5. vue数据传递的特殊实现技巧

    最近碰到了比较多的关于vue的eventBus的问题,之前定技术选型的时候也被问到了,vuex和eventBus的使用范围.所以简单的写一下.同时有一种特殊的实现方案. 有这么几种数据传递方式,vue ...

  6. centos下yum安装pip失败

    [root@wfm ~]# yum -y install pip Loaded plugins: fastestmirror, refresh-packagekit, securityLoading ...

  7. Jmeter 在linux下的分布式压测

    Jmeter 在linux下的分布式压测 0.将 windows机器作为master 控制机(同时也兼做负载机slave), linux机器作为 负载机 slave. 1.linux环境安装 : (1 ...

  8. JUC集合之 ConcurrentLinkedQueue

    ConcurrentLinkedQueue介绍 ConcurrentLinkedQueue是线程安全的队列,它适用于"高并发"的场景. 它是一个基于链接节点的无界线程安全队列,按照 ...

  9. golang sizeof 占用空间大小

    C语言中,可以使用sizeof()计算变量或类型占用的内存大小.在Go语言中,也提供了类似的功能, 不过只能查看变量占用空间大小.具体使用举例如下. package main import ( &qu ...

  10. 最新hadoop虚拟机安装教程(附带图文)

    前两天看到有人留言问在什么情况下需要部署hadoop,我给的回答也很简单,就是在需要处理海量数据的时候才需要考虑部署hadoop.关于这个问题在很早之前的一篇分享文档也有说到这个问题,数据量少的完全发 ...