Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For a 0.2.1 release #9

Merged
merged 4 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name = "LearnTestAPI"
uuid = "3111ed91-c4f2-40e7-bb19-7f6c618409b8"
authors = ["Anthony D. Blaom <[email protected]>"]
version = "0.2.0"
version = "0.2.1"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
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"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/LearnTestAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module LearnTestAPI
using LearnAPI
import Test
import Serialization
import MLUtils
import MLCore
import StableRNGs
import InteractiveUtils
import MacroTools
Expand Down
10 changes: 5 additions & 5 deletions src/learners/ensembling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand All @@ -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 = """
Expand Down
4 changes: 2 additions & 2 deletions src/testapi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions test/learners/regression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Test
using LearnAPI
using LinearAlgebra
using Tables
import MLUtils
import MLCore
import DataFrames
using LearnTestAPI

Expand Down Expand Up @@ -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}}
Expand All @@ -73,7 +73,7 @@ learner = LearnTestAPI.Ridge(lambda=0.5)
@test predict(
recovered_model,
Point(),
MLUtils.getobs(predictobs, test)
MLCore.getobs(predictobs, test)
) ≈ ŷ

end
Expand All @@ -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))
Expand Down
Loading