11、贝叶斯定理:原理、计算与应用

贝叶斯定理:原理、计算与应用

1. 贝叶斯方法概述

1.1 基本概念

贝叶斯建模中两个重要概念是概率和效用。概率用于建模我们对世界状态的信念,以 $p(x|C)$ 形式表示,其中 $C$ 是当前已知上下文,$x$ 是感兴趣的事件。效用用于衡量不同结果对我们的价值,成本为负效用,收益为正效用,通常以结果的函数形式表示。

1.2 贝叶斯规则

概率根据新证据或结果 $y$ 利用贝叶斯规则更新:
[p(x|C, y) = \frac{p(x|C)p(Y|x, C)}{p(y|C)}]
其中 $\Omega$ 是 $x$ 的离散域,更一般地,任何可测集都可作为域 $\Omega$。对于事件 $x$ 的效用函数 $u(x)$,其期望值为:
[E_{x|C}[u(x)] = \sum_{x\in\Omega} p(x|C)u(x)]
我们根据不同证据、行动或结果 $y$ 估计期望效用 $E_{x|C,y}[u(x)]$,并采取行动以最大化该期望效用,遵循最大期望效用(MEU)原则。

1.3 动机与背景

在建模问题时,需考虑事件、状态、行动和结果的相互关联空间。贝叶斯方法为在不确定和动态环境中进行推理和行动提供了原则性方法。该方法以托马斯·贝叶斯命名,虽最初有争议,但如今与其他统计方法共存。它可通过公理规定和一致性原则来证明其合理性,在学习中,概率用于推断模型,效用用于基于模型进行预测或分析。

2. 贝叶斯理论基础

2.1 基本定义

  • 概率 :以 $p(x|C)$ 表示

相关推荐

《Python机器学习基础教程》第二章监督学习2.9 深度解析:朴素贝叶斯分类器——从原理到应用的全面指南

自定义特征提取函数')]# 创建自定义特征提取器# 创建管道('custom', custom_transformer), # 自定义特征提取('clf', MultinomialNB()) # 朴素贝叶斯分类器])# 训练模型# 预测# 评估模型。

890

详解朴素贝叶斯的来源,原理以及实例解析

出现背景: 在贝叶斯公式出现之前,人们只会解决正向概率问题,即“假如一个袋子里有5个白球,3个黑球。现从中摸一个球,取得白球的概率。”实际上,这是从上帝视角来看待问题,在实际生活中的用途并不大。 而贝叶斯公式要解决的是逆向概率问题,即“袋子里白球和黑球两种颜色的球的个数是未知的,现从中多次摸球,推断袋中两种颜色的球各有多少。”这就很符合实际生活中的场景,站在“普通人的角度”一步步解决问题。当然,也可以细心的发现这很符合机器学习的思想,因为很明显,摸球的次数会决定推断的准确性,而一次次的摸球实际上就是一个学习

weixin_43679657的博客 2661

机器学习分类算法详解:原理、应用场景与测试用例

通过交叉验证对比不同算法在测试用例中的表现,结合实际业务需求(如精度、速度、可解释性)选择最优模型。

rockmelodies的博客 1425

11、朴素贝叶斯算法:原理、攻击与实践

本文深入探讨了朴素贝叶斯算法的原理、学习过程及其在实际中的应用,重点分析了其面临的安全威胁,包括对抗攻击、中毒攻击、模型窃取、成员推理和模型反转等。文章还提供了高斯朴素贝叶斯的实现代码与攻击实验,并提出了优化建议与应用场景拓展,最后展望了该算法在未来的发展方向。

t1u2v的博客 46

贝叶斯算法(Bayesian Algorithms) 原理与代码实例讲解

贝叶斯算法(Bayesian Algorithms) - 原理与代码实例讲解 1.背景介绍 1.1 贝叶斯算法的起源与发展 贝叶斯算法是以英国数学家托马斯·贝叶斯的名字命名的一类算法的总称。早在

AI天才研究院 1096

USB2.0信号完整性测试之眼图

名称线缆颜色引脚描述红色绿色白色GND黑色。

qq_53766840的博客 3289

无需Root!用VirtualXposed+JustTrustMe在安卓高版本上抓包拼多多API数据

本文详细介绍了在安卓高版本设备上无需Root权限即可抓取拼多多API数据的完整方案,通过VirtualXposed与JustTrustMe组合技术,有效绕过SSL Pinning限制。文章涵盖工具准备、环境配置、应用处理及实战分析,特别针对PDD应用的混合通信策略提供了专业解决方案,适合开发者进行竞品分析和数据采集。

weixin_28678151的博客 456

AutoCAD 2025在Win10/Win11上的官方安装、配置与问题排查全指南

对于需要在 Windows 11 或 Windows 10 系统上部署 AutoCAD 2025 的设计师、工程师和 IT 支持人员来说,一个稳定、合规的安装流程是高效工作的基石。网络上充斥着各种所谓的“免费下载”和“一键安装”教程,但这些资源往往来源不明,可能捆绑恶意软件、导致软件崩溃,甚至引发严重的许可合规风险。本文旨在提供一个清晰、安全、基于官方最佳实践的 AutoCAD 2025 安装与配置指南,重点解决在 Windows 11 和 Windows 10 系统上部署时可能遇到的兼容性问题、安装失败以

weixin_34396103的博客 453

STM32F407与AD7766实战:如何用SPI+DMA实现高速ADC数据采集(附完整代码)

本文详细介绍了如何利用STM32F407的SPI接口与DMA控制器,高效稳定地驱动24位高精度ADC芯片AD7766,实现高速连续数据采集。通过对比传统中断方式的瓶颈,阐述了SPI+DMA方案如何大幅降低CPU负载,并提供了从硬件设计、CubeMX配置到核心驱动代码的完整实战指南,帮助工程师解决高速ADC数据采集中的性能难题。

weixin_29281941的博客 190

【数电课程设计】---出租车计价器

文章目录1、任务要求2、方案3、收获 1、任务要求 2、方案 3、收获

LZY 1万+

Emscripten安装(wasm编译)

5:配置对应环境变量--替换成自己对应的安装路径(2025最新的Emscripten工具链默认使用LLVM/WebAssembly标准工作流,java依赖已经移除了,所以以下java环境不配,需要使用java的手动添加即可---->emsdk install java-8-152-64bit。3:下载相应的依赖库---->emsdk install latest(我这里下的是最新的,如果有指定版本,把latest替换成版本号即可)6:测试是否成功---> emcc- v/em++ -v。

qq_31578301的博客 561

Visual Studio调试时遇到ntdll.dll的PDB文件缺失?别慌,这3个方法帮你搞定(附详细步骤)

本文详细解析了Visual Studio调试时ntdll.dll的PDB文件缺失问题,提供了3种实用解决方案:调整调试设置、配置符号服务器与缓存目录、手动下载管理符号文件。通过分步指导和高级技巧,帮助开发者快速恢复完整的调试功能,特别适用于Windows平台下的C++项目开发。

weixin_42537919的博客 516

学习利用ce修改游戏生命参数

易语言代码 游戏的简陋界面 用ce查找存储这个1000即生命值的内存地址(得先附加到目标程序上,点击左上角那个电脑按钮) 看到有很多值为1000的,但哪个是生命值呢?真相只有一个 我们点击一下打我这个按钮,看下面的ce界面上地址为004A65C0处的值变了,所以这个就是我们要找的生命值 接下来我们对生命值进行修改,修改为99

zsd747289639的博客 5万+

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

上一篇: 41、探索DIMM后门:设计、实现与挑战
下一篇: 48、整数格中的算法与应用
pluto
博客等级 码龄25年 46粉丝 1562原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值