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

Why regression used in apply_forest only if type of labels in model is Float64? #225

Open
xinadi opened this issue Sep 20, 2023 · 2 comments

Comments

@xinadi
Copy link
Contributor

xinadi commented Sep 20, 2023

Hi, I found that for regression algorithm in apply_forest function (mean) the labels type T of model should be exact Float64:

function apply_forest(forest::Ensemble{S, T}, features::AbstractVector{S}) where {S, T}
    n_trees = length(forest)
    votes = Array{T}(undef, n_trees)
    for i in 1:n_trees
        votes[i] = apply_tree(forest.trees[i], features)
    end
    if T <: Float64
        return mean(votes)
    else
        return majority_vote(votes)
    end
end

Is there any particular reason why condition is not T <: AbstractFloat? Also, the documentation noted that regression choosed when labels/targets of type Float, not Float64.
Thanks!

@rikhuijzer
Copy link
Member

You are probably right. Well spotted! If you want, you can open a PR to fix this. If the tests pass, then it will most likely be merged. (Optionally, you can also do a search on the codebase for any other cases of Float64 matches to check whether there are not more cases like this.)

@ablaom
Copy link
Member

ablaom commented Sep 20, 2023

It would be good to have a more generic implementation. However, it seems that a refactor may be a little more involved. See, for example:

label::Float64 # most likely label

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants