From 38fd23ba21f409988fb33e52645b5e107a3e2d05 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Fri, 16 Feb 2024 15:38:18 +1300 Subject: [PATCH] add generic interface tests from MLJTestInterface --- Project.toml | 3 ++- test/runtests.jl | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1cf59e7..5a4497e 100644 --- a/Project.toml +++ b/Project.toml @@ -21,10 +21,11 @@ julia = "1.6" [extras] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d" +MLJTestInterface = "72560011-54dd-4dc2-94f3-c5de45b75ecd" StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" StatisticalMeasures = "a19d573c-0a75-4610-95b3-7071388c7541" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["LinearAlgebra", "MLJBase", "StableRNGs", "StatisticalMeasures", "Statistics", "Test"] +test = ["LinearAlgebra", "MLJBase", "MLJTestInterface", "StableRNGs", "StatisticalMeasures", "Statistics", "Test"] diff --git a/test/runtests.jl b/test/runtests.jl index a266fc6..82a93be 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,12 +7,62 @@ using Statistics using MLJGLMInterface using GLM: coeftable import GLM +import MLJTestInterface using Distributions: Normal, Poisson, Uniform import StableRNGs using Tables expit(X) = 1 ./ (1 .+ exp.(-X)) + +# TODO: Add more datasets to the following generic interface tests after #45 is merged + +@testset "generic interface tests" begin + @testset "LinearRegressor" begin + for data in [ + MLJTestInterface.make_regression(), + ] + failures, summary = MLJTestInterface.test( + [LinearRegressor,], + data...; + mod=@__MODULE__, + verbosity=0, # bump to debug + throw=false, # set to true to debug + ) + @test isempty(failures) + end + end + + @testset "LinearCountRegressor" begin + for data in [ + MLJTestInterface.make_count(), + ] + failures, summary = MLJTestInterface.test( + [LinearCountRegressor,], + data...; + mod=@__MODULE__, + verbosity=0, # bump to debug + throw=false, # set to true to debug + ) + @test isempty(failures) + end + end + + @testset "LinearBinaryClassifier" begin + for data in [ + MLJTestInterface.make_binary(), + ] + failures, summary = MLJTestInterface.test( + [LinearBinaryClassifier,], + data...; + mod=@__MODULE__, + verbosity=0, # bump to debug + throw=false, # set to true to debug + ) + end + end +end + ### ### OLSREGRESSOR ###