Python 3.x 如果观测值是模糊规则的输出,如何计算后验概率
以下示例来自: 如果活动状态(观察到的变量)不是一个分类集,而是属于每个活动的模糊成员激活分布,我应该如何使用Bayespy?例如,与步行、清洁或购物等相互独立的活动状态不同,人们可以在模糊的框架中同时步行和购物,例如80%步行和20%清洁,因此:Python 3.x 如果观测值是模糊规则的输出,如何计算后验概率,python-3.x,bayesian-networks,inference,fuzzy,Python 3.x,Bayesian Networks,Inference,Fuzzy,以下示例来自: 如果活动状态(观察到的变量)不是一个分类集,而是属于每个活动的模糊成员激活分布,我应该如何使用Bayespy?例如,与步行、清洁或购物等相互独立的活动状态不同,人们可以在模糊的框架中同时步行和购物,例如80%步行和20%清洁,因此: 我应该为我的模糊观察活动定义什么模型(高斯模型、分类模型、混合模型等)?i、 e.用什么来改变分类 activity=mixed(天气,分类,p).random() a0 = [0.6, 0.4] # p(rainy)=0.6, p(sunny
- 我应该为我的模糊观察活动定义什么模型(高斯模型、分类模型、混合模型等)?i、 e.用什么来改变分类
activity=mixed(天气,分类,p).random()
a0 = [0.6, 0.4] # p(rainy)=0.6, p(sunny)=0.4
A = [[0.7, 0.3], # p(rainy->rainy)=0.7, p(rainy->sunny)=0.3
[0.4, 0.6]] # p(sunny->rainy)=0.4, p(sunny->sunny)=0.6
N = 100 # will be observing 100 samples
# discrete first-order Markov chain is constructed as
from bayespy.nodes import CategoricalMarkovChain
Z = CategoricalMarkovChain(a0, A, states=N)
# observations
# probability of each activity depends on the current weather
P = [[0.1, 0.4, 0.5], # walk, shop, clean for rainy weather
[0.6, 0.3, 0.1]]
# observed process using P and chain Z
from bayespy.nodes import Categorical, Mixture
Y = Mixture(Z, Categorical, P)
# DATA
# generate artificial data from the model itself.
# Realisation of weather process
weather = Z.random()
# using weather process, draw realisations of activities
activity = Mixture(weather, Categorical, P).random()
# INFERENCE
#using weather and activities data,
#we set our variable Y to be observed:
Y.observe(activity)
# variational Bayesian inference engine with all random variables
from bayespy.inference import VB
Q = VB(Y, Z)
# is only one unobserved random variable, we recover the exact posterior
distribution
Q.update()