MLBase.jl icon indicating copy to clipboard operation
MLBase.jl copied to clipboard

confusmat() errors if class contains 0

Open asbisen opened this issue 7 years ago • 1 comments

if the classes in gt or pred contains 0 the function confusmat errors out with the following error.

gr=[0,1,0,1]
pr=[0,0,1,1]
confusmat(2, gr, pr)

ERROR: BoundsError: attempt to access 2×2 Array{Int64,2} at index [0,0]
 in confusmat(::Int64, ::Array{Int64,1}, ::Array{Int64,1}) at /Users/abisen/.julia/v0.5/MLBase/src/perfeval.jl:17

where as if the classes does not contain 0 everything works

gr=[1,2,1,2]
pr=[1,1,2,2]
confusmat(2, gr, pr)

2×2 Array{Int64,2}:
 1  1
 1  1

asbisen avatar Mar 01 '17 05:03 asbisen

Created a pull request https://github.com/JuliaStats/MLBase.jl/pull/46 that closes this issue.

asbisen avatar Sep 04 '18 05:09 asbisen