机器学习中的两个概率模型

discriminative model 和 generative model是机器学习算法中两种概率模型,用来实现对训练样本的概率分布进行建模,在实践中由于经常混淆,现在通过查阅资料,将两者的分别总结于此。

不妨用stackoverflow上的一段描述来开启这个话题:

Let’s say you have input data x and you want to classify the data into labels y. A generative model learns the joint probability distribution p(x,y) and a discriminative model learns the conditional probability distribution p(y|x) - which you should read as “the probability of y given x”. Here’s a really simple example. Suppose you have the following data in the form (x,y):(1,0),(1,0),(2,0),(2,1)

p(x,y) is

p(x,y) y=0 y=1
x=1 12 0
x=2 14 14


p(y|x) is

p(y|x) y=0 y=1
x=1 1 0
x=2 12 12

If you take a few minutes to stare at those two matrices, you will understand the difference between the two probability distributions. The distribution p(y|x) is the natural distribution for classifying a given example x into a class y, which is why algorithms that model this directly are called discriminative algorithms. Generative algorithms model p(x,y), which can be tranformed into p(y|x) by applying Bayes rule and then used for classification. However, the distribution p(x,y) can also be used for other purposes. For example you could use p(x,y) to generate likely (x,y) pairs. From the description above you might be thinking that generative models are more generally useful and therefore better, but it’s not as simple as that. The overall gist is that discriminative models generally outperform generative models in classification tasks.



Generative models are used in machine learning for either modeling data directly (i.e., modeling observations drawn from a probability density function), or as an intermediate step to forming a conditional probability density function. A conditional distribution can be formed from a generative model through Bayes’ rule.



生成模型是对样本数据的联合概率p(x,y)进行建模,建模得到的联合概率p(x,y)可以用来生成数据对(x,y),所以被称为生成模型。而判别模型则是对条件概率p(y|x)进行建模,即给定x对应y的概率。而通过生成模型是可通过贝叶斯公式推导至判别模型,而从判别模型无法推导至生成模型。p(x,y)=p(x|y)p(y),在进行建模的时候,生成模型在训练样本中将对(以二分类问题为例)y=0时样本的特征分布和y=1时样本的特征分布分别进行建模,然后还需对训练样本中的y的先验概率p(y)进行建模。当输入新的无标签样本进行测试时,只需通过计算。而判别模型则比较简单,直接通过计算p(x,y=1)=p(x|y=1)p(y=1)用来代替p(y=1|x)和p(y=0|x),并比较两者大小来判定类别归属。而对于判别模型则直接对后验概率模型p(y|x)进行建模,比如logistic regression和linear regression等。在测试时,对于无标签样本,直接输入到概率模型中就能得到对应的y值,如果是二分类问题,就可以通过输出p(y=1|x)的概率是否大于0.5为标准来判定归属。



Although this topic is quite old, I think it’s worth to add this important distinction. In practice the models are used as follows.

In discriminative models to predict the label y from the training example x, you must evaluate:

f(x)=arg maxy p(y|x)

Which merely chooses what is the most likely class considering x. It’s like we were trying to model the decision boundary between the classes. This behavior is very clear in neural networks, where the computed weights can be seen as a complex shaped curve isolating the elements of a class in the space.

Now using Bayes’ rule, let’s replace the p(y|x) in the equation by p(x|y)p(y)p(x). Since you are just interested in the arg max, you can wipe out the denominator, that will be the same for every y. So you are left with

f(x)=arg maxy p(x|y)p(y)

Which is the equation you use in generative models. While in the first case you had the conditional probability distribution p(y|x), which modeled the boundary between classes, in the second you had the joint probability distribution p(x,y), since p(x,y)=p(x|y)p(y), which explicitly models the actual distribution of each class.

With the joint probability distribution function, given an y, you can calculate (“generate”) its respective x. For this reason they are called generative models.



Imagine your task is to classify a speech to a language:

you can do it either by:

1) Learning each language and then classifying it using the knowledge you just gained

OR

2) Determining the difference in the linguistic models without learning the languages and then classifying the speech.

the first one is the Generative Approach and the second one is the Discriminative approach.



Examples of discriminative models used in machine learning include:

  • Logistic regression
  • Support vector machines
  • Boosting (meta-algorithm)
  • Conditional random fields
  • Linear regression
  • Neural networks

Examples of generative models include:

  • Gaussian mixture model and other types of mixture model
  • Hidden Markov model
  • Probabilistic context-free grammar
  • Naive Bayes
  • Averaged one-dependence estimators
  • Latent Dirichlet allocation
  • Restricted Boltzmann machine

2015-8-31 艺少

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-07 07:22:09

机器学习中的两个概率模型的相关文章

机器学习中的范数规则化之(一)L0、L1与L2范数

机器学习中的范数规则化之(一)L0.L1与L2范数 [email protected] http://blog.csdn.net/zouxy09 转自:http://blog.csdn.net/zouxy09/article/details/24971995 今天我们聊聊机器学习中出现的非常频繁的问题:过拟合与规则化.我们先简单的来理解下常用的L0.L1.L2和核范数规则化.最后聊下规则化项参数的选择问题.这里因为篇幅比较庞大,为了不吓到大家,我将这个五个部分分成两篇博文.知识有限,以下都是我一

机器学习中的有监督学习,无监督学习,半监督学习

在机器学习(Machine learning)领域.主要有三类不同的学习方法: 监督学习(Supervised learning). 非监督学习(Unsupervised learning). 半监督学习(Semi-supervised learning), 监督学习:通过已有的一部分输入数据与输出数据之间的相应关系.生成一个函数,将输入映射到合适的输出,比如分类. 非监督学习:直接对输入数据集进行建模,比如聚类. 半监督学习:综合利用有类标的数据和没有类标的数据,来生成合适的分类函数. 一.监

机器学习中的矩阵方法04:SVD 分解

机器学习中的矩阵方法04:SVD 分解 前面我们讲了 QR 分解有一些优良的特性,但是 QR 分解仅仅是对矩阵的行进行操作(左乘一个酉矩阵),可以得到列空间.这一小节的 SVD 分解则是将行与列同等看待,既左乘酉矩阵,又右乘酉矩阵,可以得出更有意思的信息.奇异值分解( SVD, Singular Value Decomposition ) 在计算矩阵的伪逆( pseudoinverse ),最小二乘法最优解,矩阵近似,确定矩阵的列向量空间,秩以及线性系统的解集空间都有应用. 1. SVD 的形式

机器学习中的数理统计与参数估计

概率统计与机器学习的关系 概率问题是已知整体的情况下判定样本(整体推个体) 统计问题是概率问题的逆向工程(个体推整体) 机器学习监督学习中,首先根据样本及样本标签训练出模型(个体推整体),再根据模型对样本标签进行预测(整体推个体). 统计估计的是分布,机器学习训练出来的是模型,模型可能包含了很多分布. 训练与预测过程的一个核心评价指标就是模型的误差. 误差本身就可以是概率的形式,与概率紧密相关. 对误差的不同定义方式就演化成了不同损失函数的定义方式. 机器学习是概率与统计的进阶版本.(不严谨的说

机器学习中的数据清洗与特征处理综述

背景 随着美团交易规模的逐步增大,积累下来的业务数据和交易数据越来越多,这些数据是美团做为一个团购平台最宝贵的财富.通过对这些数据的分析和挖掘,不仅能给美团业务发展方向提供决策支持,也为业务的迭代指明了方向.目前在美团的团购系统中大量地应用到了机器学习和数据挖掘技术,例如个性化推荐.筛选排序.搜索排序.用户建模等等,为公司创造了巨大的价值.本文主要介绍在美团的推荐与个性化团队实践中的数据清洗与特征挖掘方法.主要内容已经在内部公开课"机器学习InAction系列"讲过,本博客的内容主要是

【转载】机器学习中的相似性度量,方法汇总对比

机器学习中的相似性度量,方法汇总对比 人工智能  林  1周前 (01-10)  876℃  0评论 作者:苍梧 在做分类时常常需要估算不同样本之间的相似性度量(Similarity Measurement),这时通常采用的方法就是计算样本间的“距离”(Distance).采用什么样的方法计算距离是很讲究,甚至关系到分类的正确与否. 本文的目的就是对常用的相似性度量作一个总结. 本文目录: 1. 欧氏距离 2. 曼哈顿距离 3. 切比雪夫距离 4. 闵可夫斯基距离 5. 标准化欧氏距离 6. 马

机器学习中的范数规则化

机器学习中的范数规则化之(一)L0.L1与L2范数 [email protected] http://blog.csdn.net/zouxy09 今天我们聊聊机器学习中出现的非常频繁的问题:过拟合与规则化.我们先简单的来理解下常用的L0.L1.L2和核范数规则化.最后聊下规则化项参数的选择问题.这里因为篇幅比较庞大,为了不吓到大家,我将这个五个部分分成两篇博文.知识有限,以下都是我一些浅显的看法,如果理解存在错误,希望大家不吝指正.谢谢. 监督机器学习问题无非就是"minimizeyour er

(转)机器学习中的损失函数

损失函数(loss function)是用来估量你模型的预测值f(x)与真实值Y的不一致程度,它是一个非负实值函数,通常使用L(Y, f(x))来表示,损失函数越小,模型的鲁棒性就越好.损失函数是经验风险函数的核心部分,也是结构风险函数重要组成部分.模型的结构风险函数包括了经验风险项和正则项,通常可以表示成如下式子: 其中,前面的均值函数表示的是经验风险函数,L代表的是损失函数,后面的ΦΦ是正则化项(regularizer)或者叫惩罚项(penalty term),它可以是L1,也可以是L2,或

机器学习中的贝叶斯方法---先验概率、似然函数、后验概率的理解及如何使用贝叶斯进行模型预测(2)

在 机器学习中的贝叶斯方法---先验概率.似然函数.后验概率的理解及如何使用贝叶斯进行模型预测(1)文章中介绍了先验分布和似然函数,接下来,将重点介绍后验概率,以及先验概率.似然函数.后验概率三者之间的关系---贝叶斯公式. 在这篇文章中,我们通过最大化似然函数求得的参数 r 与硬币的抛掷次数(抛掷次数是10,求得的r=0.9)有关,为了更好地描述 参数 r 与 抛掷次数之间的关系,对下面符号作一些说明: 参数 r :抛一次硬币出现正面的概率,显然 r 的取值范围为[0,1] yN,在N次抛硬币