diff --git a/Project.toml b/Project.toml index caecbaa..8ccfe04 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LearnTestAPI" uuid = "3111ed91-c4f2-40e7-bb19-7f6c618409b8" authors = ["Anthony D. Blaom "] -version = "0.2.0" +version = "0.2.1" [deps] Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" @@ -9,7 +9,7 @@ InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" IsURL = "ceb4388c-583f-448d-bb30-00b11e8c5682" LearnAPI = "92ad9a40-7767-427a-9ee6-6e577f1266cb" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54" +MLCore = "c2834f40-e789-41da-a90e-33b280584a8c" MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" ScientificTypes = "321657f4-b219-11e9-178b-2701a2544e81" @@ -27,7 +27,7 @@ InteractiveUtils = "<0.0.1, 1" IsURL = "0.2.0" LearnAPI = "0.2.0" LinearAlgebra = "<0.0.1, 1" -MLUtils = "0.4" +MLCore = "1.0.0" MacroTools = "0.5" Random = "<0.0.1, 1" ScientificTypes = "3.0.2" diff --git a/src/LearnTestAPI.jl b/src/LearnTestAPI.jl index 4a223b2..9c15c20 100644 --- a/src/LearnTestAPI.jl +++ b/src/LearnTestAPI.jl @@ -30,7 +30,7 @@ module LearnTestAPI using LearnAPI import Test import Serialization -import MLUtils +import MLCore import StableRNGs import InteractiveUtils import MacroTools diff --git a/src/learners/ensembling.jl b/src/learners/ensembling.jl index eb6dd7b..2894d17 100644 --- a/src/learners/ensembling.jl +++ b/src/learners/ensembling.jl @@ -76,7 +76,7 @@ function LearnAPI.fit(learner::Ensemble, data; verbosity=1) rng = deepcopy(learner.rng) # to prevent mutation of `learner`! n = learner.n - # ensure data can be subsampled using MLUtils.jl, and that we're feeding the atomic + # ensure data can be subsampled using MLCore.jl, and that we're feeding the atomic # `fit` data in an efficient (pre-processed) form: observations = obs(atom, data) @@ -85,12 +85,12 @@ function LearnAPI.fit(learner::Ensemble, data; verbosity=1) models = [] # get number of observations: - N = MLUtils.numobs(observations) + N = MLCore.numobs(observations) # train the ensemble: for _ in 1:n bag = rand(rng, 1:N, N) - data_subset = MLUtils.getobs(observations, bag) + data_subset = MLCore.getobs(observations, bag) # step down one verbosity level in atomic fit: model = fit(atom, data_subset; verbosity=verbosity - 1) push!(models, model) @@ -125,7 +125,7 @@ function LearnAPI.update( atom = learner.atom observations = obs(atom, data) - N = MLUtils.numobs(observations) + N = MLCore.numobs(observations) # initialize: models = model.models @@ -134,7 +134,7 @@ function LearnAPI.update( # add new regressors to the ensemble: for _ in 1:Δn bag = rand(rng, 1:N, N) - data_subset = MLUtils.getobs(observations, bag) + data_subset = MLCore.getobs(observations, bag) model = fit(atom, data_subset; verbosity=verbosity-1) push!(models, model) end diff --git a/src/logging.jl b/src/logging.jl index 806837b..346bb89 100644 --- a/src/logging.jl +++ b/src/logging.jl @@ -211,7 +211,7 @@ const SELECTED_FOR_FIT = """ Testing that we can select all observations from `_data = LearnAPI.obs(learner, data)`, using the interface declared by `LearnAPI.data_interface(learner)`. For example, if this interface is `LearnAPI.RandomAccess()`, the attempted selection is - `data3 = MLUtils.getobs(_data, 1:MLUtils.numobs(_data))`. For this interface, also + `data3 = MLCore.getobs(_data, 1:MLCore.numobs(_data))`. For this interface, also testing that we can call `fit` on the selection, obtaining a new `fit` result `model3`. @@ -221,7 +221,7 @@ const SELECTED = """ Testing that we can select all observations from `_X = LearnAPI.obs(model, X)`, using the interface declared by `LearnAPI.data_interface(learner)`. For example, if this interface is `LearnAPI.RandomAccess()`, the attempted selection is - `X3 = MLUtils.getobs(_X, 1:MLUtils.numobs(_X))`. + `X3 = MLCore.getobs(_X, 1:MLCore.numobs(_X))`. """ const PREDICT_ON_SELECTIONS1 = """ diff --git a/src/testapi.jl b/src/testapi.jl index 11d9b3b..48d6f38 100644 --- a/src/testapi.jl +++ b/src/testapi.jl @@ -48,7 +48,7 @@ The following are *not* tested: - The veracity of `LearnAPI.is_pure_julia(learner)`. - The second of the two contracts appearing in the - [`LearnAPI.target_observation_scitype`](@extref) docstring. The first contract is only + [`LearnAPI.target_observation_scitype`](@ref) docstring. The first contract is only tested if `LearnAPI.data_interface(learner)` is `LearnAPI.RandomAccess()` or `LearnAPI.FiniteIterable()`. @@ -78,7 +78,7 @@ macro testapi(learner, data...) quote import LearnTestAPI.Test import LearnTestAPI.Serialization - import LearnTestAPI.MLUtils + import LearnTestAPI.MLCore import LearnTestAPI.LearnAPI import LearnTestAPI.InteractiveUtils import LearnTestAPI: @logged_testset, @nearly diff --git a/src/tools.jl b/src/tools.jl index c53a590..910e939 100644 --- a/src/tools.jl +++ b/src/tools.jl @@ -62,8 +62,8 @@ const ERR_BAD_LENGTH = ErrorException( function get(learner_or_model, data, ::LearnAPI.RandomAccess, apply) observations = LearnAPI.obs(learner_or_model, data) |> apply - n = MLUtils.numobs(observations) - return MLUtils.getobs(observations, 1:n) + n = MLCore.numobs(observations) + return MLCore.getobs(observations, 1:n) end function get(learner_or_model, data, ::LearnAPI.FiniteIterable, apply) observations = LearnAPI.obs(learner_or_model, data)|> apply diff --git a/test/learners/regression.jl b/test/learners/regression.jl index 52e9e53..f90b409 100644 --- a/test/learners/regression.jl +++ b/test/learners/regression.jl @@ -2,7 +2,7 @@ using Test using LearnAPI using LinearAlgebra using Tables -import MLUtils +import MLCore import DataFrames using LearnTestAPI @@ -55,9 +55,9 @@ learner = LearnTestAPI.Ridge(lambda=0.5) fitobs = LearnAPI.obs(learner, data) predictobs = LearnAPI.obs(model, X) - model = fit(learner, MLUtils.getobs(fitobs, train); verbosity=0) + model = fit(learner, MLCore.getobs(fitobs, train); verbosity=0) @test LearnAPI.target(learner, fitobs) == y - @test predict(model, Point(), MLUtils.getobs(predictobs, test)) ≈ ŷ + @test predict(model, Point(), MLCore.getobs(predictobs, test)) ≈ ŷ @test predict(model, LearnAPI.features(learner, fitobs)) ≈ predict(model, X) @test LearnAPI.feature_importances(model) isa Vector{<:Pair{Symbol}} @@ -73,7 +73,7 @@ learner = LearnTestAPI.Ridge(lambda=0.5) @test predict( recovered_model, Point(), - MLUtils.getobs(predictobs, test) + MLCore.getobs(predictobs, test) ) ≈ ŷ end @@ -91,9 +91,9 @@ learner = LearnTestAPI.BabyRidge(lambda=0.5) fitobs = obs(learner, data) predictobs = LearnAPI.obs(model, X) - model = fit(learner, MLUtils.getobs(fitobs, train); verbosity=0) - @test predict(model, Point(), MLUtils.getobs(predictobs, test)) == ŷ == - predict(model, MLUtils.getobs(predictobs, test)) + model = fit(learner, MLCore.getobs(fitobs, train); verbosity=0) + @test predict(model, Point(), MLCore.getobs(predictobs, test)) == ŷ == + predict(model, MLCore.getobs(predictobs, test)) @test LearnAPI.target(learner, data) == y @test LearnAPI.predict(model, X) ≈ LearnAPI.predict(model, LearnAPI.features(learner, data))