Skip to content

Commit

Permalink
overload constructor trait for EnsembleModel types
Browse files Browse the repository at this point in the history
  • Loading branch information
ablaom committed Jun 3, 2024
1 parent 4b91b75 commit 615b95a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/ensembles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ _reducer(p, q) = vcat(p, q)
_reducer(p::Tuple, q::Tuple) = (vcat(p[1], q[1]), vcat(p[2], q[2]))



# # ENSEMBLE MODEL TYPES

mutable struct DeterministicEnsembleModel{Atom<:Deterministic} <: Deterministic
Expand Down Expand Up @@ -638,11 +637,8 @@ end

# Note: input and target traits are inherited from atom

MMI.load_path(::Type{<:ProbabilisticEnsembleModel}) =
"MLJ.ProbabilisticEnsembleModel"
MMI.load_path(::Type{<:DeterministicEnsembleModel}) =
"MLJ.DeterministicEnsembleModel"

MMI.load_path(::Type{<:EitherEnsembleModel}) = "MLJEnsembles.EnsembleModel"
MMI.constructor(::Type{<:EitherEnsembleModel}) = EnsembleModel
MMI.is_wrapper(::Type{<:EitherEnsembleModel}) = true
MMI.supports_weights(::Type{<:EitherEnsembleModel{Atom}}) where Atom =
MMI.supports_weights(Atom)
Expand Down
3 changes: 3 additions & 0 deletions test/ensembles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ X = MLJEnsembles.table(ones(5,3))
y = categorical(collect("asdfa"))
train, test = partition(1:length(y), 0.8);
ensemble_model = EnsembleModel(model=atom)
@test constructor(ensemble_model) == EnsembleModel
@test load_path(ensemble_model) == "MLJEnsembles.EnsembleModel"
@test package_name(ensemble_model) == "MLJEnsembles"
ensemble_model.n = 10
fitresult, cache, report = MLJEnsembles.fit(ensemble_model, 0, X, y)
predict(ensemble_model, fitresult, MLJEnsembles.selectrows(X, test))
Expand Down

0 comments on commit 615b95a

Please sign in to comment.