dotnet / infer

Infer.NET is a framework for running Bayesian inference in graphical models
https://dotnet.github.io/infer/
MIT License
1.55k stars 231 forks source link

Exception: Improper distribution during inference #142

Open caxelrud opened 5 years ago

caxelrud commented 5 years ago

Need some help. InferNet_2019.zip

I converted the DifficultyAbility.cs code from C# to F#. But, I am getting the exception "Microsoft.ML.Probabilistic.Factors.ImproperMessageException: Improper distribution during inference (Gaussian(m/v=-0.01752, 1/v=0)). Cannot perform inference on this model" The source code and executions results are attached.

tminka commented 5 years ago

Thanks for converting this example. I will add this code to the TestFSharp folder, if you don't mind.

I am not able to reproduce the error that you are seeing. I get the following result:

Compiling model...done.
Iterating:
..... 5
99.000000 TrueAnswers correct
difficulty[0] = Gaussian(1.914, 0.3346) (sampled from 2.374285)
difficulty[1] = Gaussian(-0.2033, 0.08233) (sampled from -0.238398)
difficulty[2] = Gaussian(-0.341, 0.0806) (sampled from -0.212323)
difficulty[3] = Gaussian(-0.03086, 0.08715) (sampled from 0.263200)
discrimination[0] = Gamma(101.1, 0.00994)[mean=1.005] (sampled from 0.997799)
discrimination[1] = Gamma(104.1, 0.0096)[mean=0.9995] (sampled from 1.053059)
discrimination[2] = Gamma(104.4, 0.009614)[mean=1.004] (sampled from 1.088694)
discrimination[3] = Gamma(103.6, 0.009661)[mean=1.001] (sampled from 0.873162)
ability[0] = Gaussian(0.2524, 0.03589) (sampled from 0.579576)
ability[1] = Gaussian(0.5612, 0.03622) (sampled from 0.812904)
ability[2] = Gaussian(1.335, 0.04739) (sampled from 1.514625)
ability[3] = Gaussian(0.171, 0.03551) (sampled from 0.328675)
caxelrud commented 5 years ago

Hi, Thanks for replying. I am happy to contribute to the TestFSharp folder ("i don't mind if add the code to the TestFSharp folder"). I have several other Infer.net conversions to F#. I will send you soon. For this case, I am still have the same error. I am running using F# interactive that is integrated with Visual Studio Code. The other examples worked fine. Please, let me know if you environment is different and I can adjust.

Regards, Celso

On Fri, Mar 29, 2019 at 10:34 AM Tom Minka notifications@github.com wrote:

Thanks for converting this example. I will add this code to the TestFSharp folder, if you don't mind.

I am not able to reproduce the error that you are seeing. I get the following result:

Compiling model...done. Iterating: ..... 5 99.000000 TrueAnswers correct difficulty[0] = Gaussian(1.914, 0.3346) (sampled from 2.374285) difficulty[1] = Gaussian(-0.2033, 0.08233) (sampled from -0.238398) difficulty[2] = Gaussian(-0.341, 0.0806) (sampled from -0.212323) difficulty[3] = Gaussian(-0.03086, 0.08715) (sampled from 0.263200) discrimination[0] = Gamma(101.1, 0.00994)[mean=1.005] (sampled from 0.997799) discrimination[1] = Gamma(104.1, 0.0096)[mean=0.9995] (sampled from 1.053059) discrimination[2] = Gamma(104.4, 0.009614)[mean=1.004] (sampled from 1.088694) discrimination[3] = Gamma(103.6, 0.009661)[mean=1.001] (sampled from 0.873162) ability[0] = Gaussian(0.2524, 0.03589) (sampled from 0.579576) ability[1] = Gaussian(0.5612, 0.03622) (sampled from 0.812904) ability[2] = Gaussian(1.335, 0.04739) (sampled from 1.514625) ability[3] = Gaussian(0.171, 0.03551) (sampled from 0.328675)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dotnet/infer/issues/142#issuecomment-478042927, or mute the thread https://github.com/notifications/unsubscribe-auth/ACOPq05Ft0mF6nyr7gHvUqg4jNPYxE5Sks5vbjKSgaJpZM4cFYkW .

tminka commented 5 years ago

I am using .NET framework version 4.0.30319.42000 mscorlib 4.7.3324.0 from Visual Studio 2017 15.9.8. It also works under .NET Core version 4.0.30319.42000 mscorlib 4.6.27317.03 @BuiltBy: dlab14-DDVSOWINAGE101 @Branch: release/2.1 @SrcCode: https://github.com/dotnet/coreclr/tree/67716e18103217d501c5901e5a7e9c4da7d044c8

tminka commented 5 years ago

You can find the code that I used at DifficultyAbility.fs.

caxelrud commented 5 years ago

I created a github to place F# and infer.NET resources at: https://github.com/caxelrud/Fsharp-and-infer.NET

At the moment, I added a Jupyter/F# version of BugRats case. I will add other examples soon.

Regards,Celso

On Mon, Apr 1, 2019 at 4:54 PM Tom Minka notifications@github.com wrote:

You can find the code that I used at DifficultyAbility.fs https://github.com/dotnet/infer/blob/master/test/TestFSharp/DifficultyAbility.fs .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dotnet/infer/issues/142#issuecomment-478761918, or mute the thread https://github.com/notifications/unsubscribe-auth/ACOPq47B_A69lhmlPIO7Hgljg1It_RnDks5vcoAPgaJpZM4cFYkW .