From 003aee0d2306603f3027d494a865d90ef61b48f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20=C5=9Een=C3=B6z?= Date: Wed, 10 Jul 2024 13:37:41 +0300 Subject: [PATCH 1/4] add projection tests for Categorical --- .../projected_to_categorical_tests.jl | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/projection/projected_to_categorical_tests.jl diff --git a/test/projection/projected_to_categorical_tests.jl b/test/projection/projected_to_categorical_tests.jl new file mode 100644 index 0000000..bb16424 --- /dev/null +++ b/test/projection/projected_to_categorical_tests.jl @@ -0,0 +1,35 @@ +@testitem "Simple projection to `Categorical`" begin + using BayesBase, ExponentialFamily, Distributions, JET + using ExponentialFamilyProjection + + include("./projected_to_setuptests.jl") + + @testset let distribution = Categorical([1/3, 1/3, 1/3]) + @test test_projection_convergence(distribution) + end + + @testset let distribution = Categorical([1/4, 1/2, 1/4]) + @test test_projection_convergence(distribution) + end + + @testset let distribution = Categorical([1/16, 1/2, 1/4, 3/16]) + @test test_projection_convergence(distribution) + end + + @testset let distribution = Categorical([1/12, 1/3, 1/12, 1/6, 1/3]) + @test test_projection_convergence(distribution) + end + + +end + + +@testitem "Project a product of `Categorical` and `Categorical` to `Categorical`" begin + using BayesBase, ExponentialFamily, Distributions + + include("./projected_to_setuptests.jl") + + @testset let distribution = ProductOf(Categorical([1/3, 1/3, 1/3]), Categorical([1/8, 1/8, 3/4])) + @test test_projection_convergence(distribution, to = Categorical, dims = (), conditioner = 3) + end +end \ No newline at end of file From 1bb49ac0eaa329522f22681b00a94252543ae555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20=C5=9Een=C3=B6z?= Date: Thu, 25 Jul 2024 17:49:23 +0300 Subject: [PATCH 2/4] mle tests are broken --- .../projected_to_categorical_tests.jl | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/projection/projected_to_categorical_tests.jl b/test/projection/projected_to_categorical_tests.jl index bb16424..7481826 100644 --- a/test/projection/projected_to_categorical_tests.jl +++ b/test/projection/projected_to_categorical_tests.jl @@ -32,4 +32,31 @@ end @testset let distribution = ProductOf(Categorical([1/3, 1/3, 1/3]), Categorical([1/8, 1/8, 3/4])) @test test_projection_convergence(distribution, to = Categorical, dims = (), conditioner = 3) end +end + + + +@testitem "MLE" begin + using BayesBase, ExponentialFamily, Distributions, JET + using ExponentialFamilyProjection + + include("./projected_to_setuptests.jl") + + @testset let distribution = Categorical([1/3, 1/3, 1/3]) + @test test_projection_mle(distribution) + end + + @testset let distribution = Categorical([1/4, 1/2, 1/4]) + @test test_projection_mle(distribution) + end + + @testset let distribution = Categorical([1/16, 1/2, 1/4, 3/16]) + @test test_projection_mle(distribution) + end + + @testset let distribution = Categorical([1/12, 1/3, 1/12, 1/6, 1/3]) + @test test_projection_mle(distribution) + end + + end \ No newline at end of file From 1dec144cbb9ee58cc55b46cb7e09fc78b230dd2b Mon Sep 17 00:00:00 2001 From: Bagaev Dmitry Date: Thu, 25 Jul 2024 21:19:11 +0200 Subject: [PATCH 3/4] update minimal version of ef manifolds --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 7df6400..a032748 100644 --- a/Project.toml +++ b/Project.toml @@ -30,7 +30,7 @@ BayesBase = "1.3" Bumper = "0.6" Distributions = "0.25" ExponentialFamily = "1.5" -ExponentialFamilyManifolds = "1.2" +ExponentialFamilyManifolds = "1.3.1" FastCholesky = "1.3" FillArrays = "1" ForwardDiff = "0.10.36" From 9887a20937d398900f5908248888a568f279752e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20=C5=9Een=C3=B6z?= Date: Fri, 26 Jul 2024 08:04:05 +0300 Subject: [PATCH 4/4] change p parameter of the categorical and the product of test is broken --- test/projection/projected_to_categorical_tests.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/projection/projected_to_categorical_tests.jl b/test/projection/projected_to_categorical_tests.jl index 7481826..67ab1b4 100644 --- a/test/projection/projected_to_categorical_tests.jl +++ b/test/projection/projected_to_categorical_tests.jl @@ -29,8 +29,8 @@ end include("./projected_to_setuptests.jl") - @testset let distribution = ProductOf(Categorical([1/3, 1/3, 1/3]), Categorical([1/8, 1/8, 3/4])) - @test test_projection_convergence(distribution, to = Categorical, dims = (), conditioner = 3) + @testset let distribution = ProductOf(Categorical([3/7, 2/7, 2/7]), Categorical([1/8, 3/8, 1/2])) + @test_broken test_projection_convergence(distribution, to = Categorical, dims = (), conditioner = 3) end end @@ -46,7 +46,7 @@ end @test test_projection_mle(distribution) end - @testset let distribution = Categorical([1/4, 1/2, 1/4]) + @testset let distribution = Categorical([1/6, 3/6, 2/6]) @test test_projection_mle(distribution) end