xKDR / CRRao.jl

MIT License
35 stars 21 forks source link

GPR #119

Open MarlaJahari opened 1 year ago

MarlaJahari commented 1 year ago

added two gpr fit() functions, struct and dependencies

ayushpatnaikgit commented 1 year ago

Can you add some test cases? Can you see how tests are done for the other functions?

sourish-cmi commented 1 year ago

Can you add some test cases? Can you see how tests are done for the other functions?

Sure - I will add some tests.

sourish-cmi commented 1 year ago

I will share some test in a day or two

ayushpatnaikgit commented 1 year ago

All tests are failing @sourish-cmi, but they aren't related to this PR. We need to spend some time and fix the package.

sourish-cmi commented 1 year ago

Sorry guys I will try to put some test cases asap

sourish-cmi commented 1 year ago

@ayushpatnaikgit @MarlaJahari @ShouvikGhosh2048

Here are some tests - we should try:

Test 1:

container=fit(@formula(MPG ~0+ HP),df,GaussianProcessesRegression(),[:MPG, :HP],MeanZero(), SE(0.0,0.0),Euclidean())

Test 1a: Kernel parameters should provide values: 5.464908573213355 and 3.3936838718120708

Test 1b: Variance of observation noise = 9.667961411202336

Test 1c: Marginal Log-Likelihood = -89.745

MarlaJahari commented 1 year ago

@sourish-cmi These (exact parameters) tests were run on the function before PR was made. We got the specified values (documented as a part of test cases before function definition).

sourish-cmi commented 1 year ago

@sourish-cmi These (exact parameters) tests were run on the function before PR was made. We got the specified values (documented as a part of test cases before function definition).

I think that should be fine. The test case should be developed based on the same.

@ShouvikGhosh2048 can you please add test case?

ShouvikGhosh2048 commented 1 year ago

Should I add it to this branch, or add it after this PR is merged?

sourish-cmi commented 1 year ago

Should I add it to this branch, or add it after this PR is merged?

I think you can add this test to this branch. Once the PR is merged - give a KT to @MarlaJahari - then she can add other tests as separate PR later.

ShouvikGhosh2048 commented 1 year ago

I don't have the required permissions.

Changes to be made: 1) Create a new file test/numerical/bayesian/GaussianProcessesRegression.jl and add the following:

mtcars = dataset("datasets", "mtcars")

CRRao.set_rng(StableRNG(123))
model = fit(@formula(MPG ~ 0 + HP), mtcars, GaussianProcessesRegression(), [:MPG, :HP], MeanZero(), SE(0.0, 0.0), Euclidean())

@test get_params(model.chain)[2:3] ≈ [5.464908573213355, 3.3936838718120708]
@test noise_variance(model.chain) ≈ 9.667961411202336
@test model.chain.target ≈ -89.74473360543863

2) Change test/Project.toml to:

[deps]
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
GLM = "38e38edf-8417-5370-95a0-9cbb8c7f171a"
GaussianProcesses = "891a1506-143c-57d2-908e-e1f8e92e6de9"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

3) Change test/runtests.jl to:

using CRRao, Test, StableRNGs, Logging, RDatasets, StatsModels, GLM, Statistics, Distances
using GaussianProcesses: MeanZero, SE, get_params, noise_variance

Logging.disable_logging(Logging.Warn)

CRRao.setprogress!(false)
CRRao.set_rng(StableRNG(123))

@testset "CRRao.jl" begin
    @testset "Basic Tests" begin
        @testset "Linear Regression" begin
            include("basic/LinearRegression.jl")
        end

        @testset "Logistic Regression" begin
            include("basic/LogisticRegression.jl")
        end

        @testset "Poisson Regression" begin
            include("basic/PoissonRegression.jl")
        end

        @testset "Negative Binomial Regression" begin
            include("basic/NegBinomialRegression.jl")
        end
    end

    @testset "Numerical Tests" begin
        @testset "Random Number Generator" begin
            include("numerical/RandomNumberGenerator.jl")
        end

        @testset "Frequentist" begin
            include("numerical/frequentist/tests.jl")
        end

        @testset "Bayesian" begin
            @testset "Gaussian Processes Regression" begin
                include("numerical/bayesian/GaussianProcessesRegression.jl")
            end

            @testset "Linear Regression" begin
                include("numerical/bayesian/LinearRegression.jl")
            end

            @testset "Logistic Regression" begin
                include("numerical/bayesian/LogisticRegression.jl")
            end

            @testset "Poisson Regression" begin
                include("numerical/bayesian/PoissonRegression.jl")
            end

            @testset "Negative Binomial Regression" begin
                include("numerical/bayesian/NegBinomialRegression.jl")
            end
        end
    end
end
sourish-cmi commented 1 year ago

@ShouvikGhosh2048 @ayushpatnaikgit -- some checks are failing. Maybe some version issue. Not sure. What to do?

ShouvikGhosh2048 commented 1 year ago

Similar issue occurs in https://github.com/xKDR/CRRao.jl/issues/123

The GPR tests pass in the CI.

sourish-cmi commented 1 year ago

Similar issue occurs in #123

The GPR tests pass in the CI.

Yes - this is a recurring issue. How do we solve it?

MarlaJahari commented 1 year ago

@sourish-cmi I think it comes from ADgradient() function of the LogDensityProblemsAD.jl package. For every regression problem we're trying to specify "gradientconfig" as a parameter- but it returns that is an unsupported keyword argument. It might be possible they've made updates or changes in the version we're trying to call.

MarlaJahari commented 1 year ago

@sourish-cmi It might also be possible the Turing version (when supplying parameters in func) we're using doesn't support the keyword

sourish-cmi commented 1 year ago

@sourish-cmi It might also be possible the Turing version (when supplying parameters in func) we're using doesn't support the keyword

@MarlaJahari Strange - but possible. I think we should try to figure out exactly what changes in Turing.jl or ADgradient() are causing the problem