Skip to content

Commit

Permalink
feat(demo): majority function
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoisot committed Sep 27, 2024
1 parent 48d76a5 commit 7f204ef
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions SDeMo/src/ensembles/bagging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ is a simple majority rule.
The additional keywords arguments are passed to `predict`.
"""
function outofbag(ensemble::Bagging; thr::Float64=0.5, kwargs...)
function outofbag(ensemble::Bagging; kwargs...)
done_instances = Int64[]
outcomes = Bool[]

Expand All @@ -70,9 +70,14 @@ function outofbag(ensemble::Bagging; thr::Float64=0.5, kwargs...)
for
i in valid_models
]
push!(outcomes, count(pred) > count(pred) // 2)
push!(outcomes, majority(pred))
end
end

return ConfusionMatrix(outcomes, ensemble.model.y[done_instances], thr)
return ConfusionMatrix(outcomes, ensemble.model.y[done_instances])
end


majority(pred::Vector{Bool}) = sum(pred) > length(pred) // 2
majority(pred::BitVector) = sum(pred) > length(pred) // 2
export majority

0 comments on commit 7f204ef

Please sign in to comment.