JuliaStats / MLBase.jl

A set of functions to support the development of machine learning algorithms
MIT License
186 stars 63 forks source link

Error in the roc function? #43

Open youngjaewoo opened 6 years ago

youngjaewoo commented 6 years ago

Hi, I don't think roc function is working properly. Here's an example.

gt = [1,2,1,2,1,2,1,2,1,2] pr = [1,1,1,1,1,1,1,1,1,1] roc(gt, pr)

This produces

p = 10 n = 0 tp = 5 tn = 0 fp = 0 fn = 0

Above don't look right to me. Or perhaps, I'm using it wrongly in which updated documentation would be useful. The current documentation says,

roc(gt::AbstractArray{T,1} where T<:Integer, pr::AbstractArray{T,1} where T<:Integer) in MLBase at /Users/youngjaewoo/.julia/v0.6/MLBase/src/perfeval.jl:162

laborg commented 5 years ago

I stumbled over this too. It's not an error, just poor documentation. If you look at the code at https://github.com/JuliaStats/MLBase.jl/blob/ded7174c2e2e9e685ca32c6228ea0772e8cc6cd2/src/perfeval.jl#L141 you see its only working for binary input (binary here meaning value 0 or 1 for either ground truth or prediction).