Tuesday, June 19, 2012 8:49 AM
Goood Morning Infer.NET team and thanks for work on this wonderful library,
As a newbie in Infer.net, working in VB.NET, i am trying to test bayesian inference.
All is ok, i can create a w matrix, calculated with by this way:
Dim y_observed As VariableArray(Of Double) = Variable.Observed(Variation, r).Named("y")
Dim x_observed As VariableArray(Of Vector) = Variable.Observed(x, r).Named("x")
' Bayes Point Machine
Dim noise As Double = 0.1
y_observed(r) = Variable.GaussianFromMeanAndVariance(Variable.InnerProduct(w, x_observed(r)), noise)
I "infer" my wposterior gaussian like that: Dim wPosterior As VectorGaussian = engine.Infer(Of VectorGaussian)(w)
and i use it with a unique "Out of the Sample" observation yOTS(0) where:
Dim yOTS As VariableArray(Of Double) = Variable.Array(Of Double)(r2)
yOTS(0) = Variable.GaussianFromMeanAndVariance(Variable.InnerProduct(Variable.Random(wPosterior), xOTS_observed(0)), noise)
Finally i obtain my output, for exemple:
"output=" & engine.Infer(yOTS).ToString => output= Gaussian(0.00123, 0.1196)
My problem is quite frustrating: i can t put mean (here 0.00123) and variance (0.1196) in variables ...
I have tried moyenne = engine.Infer(yOTS).GetMean(), it should be straightforward but ... i have a bug, the error message says:
"The public member 'GetMean' from type 'DistributionStrucArray(Of Gaussain, Double)' is not found' (Rough english translation from french error message).
So, is there a simplier way to get the mean and variance, what have i to do to get these values?
Thanks for help.
Wednesday, June 20, 2012 4:30 PM
yOTS is a VariableArray, so its marginal comes out as IList<Gaussian>.
IList<Gaussian> output = engine.Infer<IList<Gaussian>>(yOTS); Console.WriteLine(output.GetMean());
- Marked As Answer by TixuOty Thursday, June 21, 2012 9:03 AM
Thursday, June 21, 2012 9:04 AM
Thx a lot Tom, it works.
it was as simple as that ...
Let s go to predict now!
See you later for another newbie question.