Skip to content

Commit

Permalink
adapting MLJInterface to nesequentialcovering parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
edo-007 committed Jun 10, 2024
1 parent f84be6a commit c765481
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/interfaces/MLJ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export OrderedCN2Learner

# using ModalDecisionTrees.MLJInterface: wrapdataset
using ModalDecisionLists
using ModalDecisionLists.LossFunctions: laplace_accuracy, entropy
using ModalDecisionLists: LossFunctions

# import ModalDecisionLists: SearchMethod, BeamSearch, RandSearch
# import ModalDecisionLists: sequentialcovering
Expand Down Expand Up @@ -100,7 +100,7 @@ function ExtendedSequentialCovering(;
searchmethod::SearchMethod=BeamSearch(),
max_rulebase_length::Union{Nothing,Integer}=nothing,
# shared parameters
loss_function::Function=entropy,
loss_function::Function=LossFunctions.entropy,
discretizedomain::Bool=false,
max_infogain_ratio::Real=1.0,
significance_alpha::Union{Real,Nothing}=0.0,
Expand Down
10 changes: 6 additions & 4 deletions src/searchmethods/randsearch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ function extract_optimalantecedent(

bestant_satmask = ones(Bool, length(y))
bestformula = begin

if !isempty(formulas)
losses = map(((rfa, satmask),) -> begin

Expand All @@ -140,15 +139,18 @@ function extract_optimalantecedent(

end, formulas)
bestindex = argmin(losses)

(bestant_formula, bestant_satmask) = formulas[bestindex]
end
if all(bestant_satmask) | (losses[bestindex] > loss_function(y, w; kwargs...))
if all(bestant_satmask) | (losses[bestindex] > loss_function(y, w; kwargs...))
bestant_formula = TOP
bestant_satmask = ones(length(y))
end
else
bestant_formula = TOP
bestant_satmask = ones(length(y))
end
(bestant_formula, bestant_satmask)
end # bestantformula

return bestformula
end

Expand Down

0 comments on commit c765481

Please sign in to comment.