bayesian

Bayesian Correlation with PyMC3

断了今生、忘了曾经 提交于 2019-12-07 14:05:10
问题 I'm trying to convert this example of Bayesian correlation for PyMC2 to PyMC3, but get completely different results. Most importantly, the mean of the multivariate Normal distribution quickly goes to zero, whereas it should be around 400 (as it is for PyMC2). Consequently, the estimated correlation quickly goes towards 1, which is wrong as well. The full code is available in this notebook for PyMC2 and in this notebook for PyMC3. The relevant code for PyMC2 is def analyze(data): # priors

Using a Naive Bayes Classifier to classify tweets: some problems

孤街醉人 提交于 2019-12-07 10:21:18
问题 Using, amongst other sources, various posts here on Stackoverflow, I'm trying to implement my own PHP classier to classify tweets into a positive, neutral and negative class. Before coding, I need to get the process straigt. My train-of-thought and an example are as follows: p(class) * p(words|class) Bayes theorem: p(class|words) = ------------------------- with p(words) assumption that p(words) is the same for every class leads to calculating arg max p(class) * p(words|class) with p(words

What are the interval transforms in pymc3 for uniform distributions?

喜夏-厌秋 提交于 2019-12-07 09:38:06
问题 I've noticed that when using uniform distributions in pymc3, the sampler also scans over an _interval parameter as well unless a transform is specified for example: with fitModel6: normMu = pm.Uniform('normMu',lower=0,upper=1000) will result in not only sampling over normMu, but also, normMu_interval: trace plot of interval trace plot of parameter Normally, when I am using an uniform prior for scale parameter like a normalization, I will of course sample over the log interval. Is pymc3

Bayesian Probabilistic Matrix Factorization (BPMF) with PyMC3: PositiveDefiniteError using `NUTS`

北城以北 提交于 2019-12-07 06:30:13
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 4 years ago . I've implemented the Bayesian Probabilistic Matrix Factorization algorithm using pymc3 in Python. I also implemented it's precursor, Probabilistic Matrix Factorization (PMF). See my previous question for a reference to the data used here. I'm having trouble drawing MCMC samples using the NUTS sampler. I initialize the model parameters using the MAP from PMF, and the

PYMC3 Seasonal Variables

ぐ巨炮叔叔 提交于 2019-12-07 03:04:01
问题 I'm relatively new to PYMC3 and I'm trying to implement a Bayesian Structure Time Series (BSTS) without regressors, for instance the model fit here in R. The model is as follows: I can implement the local linear trend using a GaussianRandomWalk as follows: delta = pymc3.GaussianRandomWalk('delta',mu=0,sd=1,shape=99) mu = pymc3.GaussianRandomWalk('mu',mu=delta,sd=1,shape=100) However, I'm at a loss for how to encode the seasonal variable (tau) in PYMC3. Do I need to roll a custom random walk

Clustering and Bayes classifiers Matlab

☆樱花仙子☆ 提交于 2019-12-06 21:55:34
问题 So I am at a cross roads on what to do next, I set out to learn and apply some machine learning algorithms on a complicated dataset and I have now done this. My plan from the very beginning was to combine two possible classifiers in an attempt to make a multi-classification system. But here is where I am stuck. I choose a clustering algorithm (Fuzzy C Means) (after learning some sample K-means stuff) and Naive Bayes as the two candidates for the MCS (Multi-Classifier System). I can use both

How to interpret the output of choicemodelr (rhierMnlRwMixture) in R

我怕爱的太早我们不能终老 提交于 2019-12-06 13:21:45
My Problem I just started using the R library 'choicemodelr' and succeded in getting some beta values as a solution. But I wonder how do I assign these values to the specific attribute-levels. As a result I only get values for A1B1, A1B2, A1B3,... etc. How does this generic output generally connect to my Design? Didn't find a hint in the documentation. Neither for the choicemodelr libraray, nor the bayesm library (rhierMnlRwMixture) to which it is connected to. I hope you can help me with this one. Thanks in advance, Phil to illustrate this, some code and output: my code in R # loading

Python NLTK not sentiment calculate correct

你离开我真会死。 提交于 2019-12-06 12:18:58
问题 I do have some positive and negative sentence. I want very simple to use Python NLTK to train a NaiveBayesClassifier for investigate sentiment for other sentence. I try to use this code, but my result is always positive. http://www.sjwhitworth.com/sentiment-analysis-in-python-using-nltk/ I am very new at python so there my be a mistake in the code when i copy it. import nltk import math import re import sys import os import codecs reload(sys) sys.setdefaultencoding('utf-8') from nltk.corpus

How to Simulate a Biased 6-sided Dice using Pymc3?

大憨熊 提交于 2019-12-06 07:49:21
How do I simulate a 6-side Dice roll using Pymc3? Also, what is I know that different sides of the dice have different distributions? The easiest way to simulate 1000 rolls of a fair 6-sided die in PyMC3 is import pymc3 as pm with pm.Model(): rolls = pm.DiscreteUniform('rolls', lower=1, upper=6) trace = pm.sample(1000) trace['rolls'] # shows you the result of 1000 rolls Note that this is slower, but equivalent, to just calling np.random.randint(1, 7, size=1000) . For 1000 rolls of an unfair die probs = np.array([0.1, 0.2, 0.3, 0.2, 0.1, 0.1]) with pm.Model(): rolls = pm.Multinomial('rolls', n

Kalman filter prediction in case of missing measurement and only positions are known

不羁岁月 提交于 2019-12-06 06:31:42
I am trying to implement Kalman filter. I only know the positions. The measurements are missing at some time steps. This is how I define my matrices: Process noise matrix Q = np.diag([0.001, 0.001] ) Measurement noise matrix R = np.diag([10, 10]) Covariance matrix P = np.diag([0.001, 0.001]) Observation matirx H = np.array([[1.0, 0.0], [0.0, 1.0]]) Transition matrix F = np.array([[1, 0], [0, 1]]) state x = np.array([pos[0], [pos[1]]) I dont know if it is right. For instance, if I see target at t=0 and dont see at t = 1 , how will I predict its position. I dont know the velocity. Are these