## ROC.jl

Receiver Operating Characteristic (ROC) Curve for Julia Language
Popularity
16 Stars
Updated Last
1 Year Ago
Started In
April 2014

# ROC

Linux, OSX:
Windows:
Code Coverage:

An implementation of ROC (Receiver Operating Characteristic) curves for Julia.

### Use

roc(scores::AbstractVector{T}, labels::AbstractVector{U}, truelabel::L; distances::Bool=false)

Here T is R or Union{R,Missing} for some type R<:Real and U is L or Union{L,Missing} for some type L<:Any. The labels vector must take exactly two non-missing values.

distances defines whether the scores values are distance-scored, i.e. a higher score value means a worse match. The default is false indicating the more typical opposite case where a higher score value means a better match

roc(scores::AbstractVector{R}, labels::BitVector{Bool}; distances::Bool=false)

Alternative method for optimal performance (no missing values allowed).

The methods above return a ROCData object, whose fields FPR and TPR are the vectors of true and false positive rates, respectively.

AUC(curve::ROCData)

Area under the curve.

PPV(curve::ROCData)

Positive predictive value.

### Example

Generate synthetic data:

julia> function noisy(label; λ=0.0)
if label
return 1 - λ*rand()
else
return λ*rand()
end
end

julia> labels = rand(Bool, 200);

julia> scores(λ) = map(labels) do label
noisy(label, λ=λ)
end

Compare area under ROC curves:

julia> using ROC

julia> roc_good = roc(scores(0.6), labels, true);
julia> roc_bad = roc(scores(1.0), labels, true);

julia> area_good = AUC(roc_good)
0.9436237564063913