Accuracy
MLMetrics.accuracy — Function.accuracy(targets, outputs, [encoding]; [normalize = true]) -> Float64Compute the fraction of correctly predicted outcomes in outputs according to the given true targets. This is known as the classification accuracy.
If encoding is omitted, the appropriate MLLabelUtils.LabelEncoding will be inferred from the types and/or values of targets and outputs. Note that omitting the encoding can cause performance penalties, which may include a lack of return-type inference.
Arguments
targets::AbstractArray: The array of ground truths $\mathbf{y}$.outputs::AbstractArray: The array of predicted outputs $\mathbf{\hat{y}}$.encoding: Optional. Specifies the possible values intargetsandoutputsand their interpretation (e.g. what constitutes as a positive or negative label, how many labels exist, etc). It can either be an object from the namespaceLabelEnc, or a vector of labels.normalize::Bool: Optional keyword argument. Iftrue, the function will return the fraction of correctly classified observations inoutputs. Otherwise it returns the total number. Defaults totrue.
See also
Examples
julia> accuracy([:a,:b,:a,:c,:c], [:a,:c,:b,:c,:c])
0.6
julia> accuracy([:a,:b,:a,:c,:c], [:a,:c,:b,:c,:c], normalize=false)
3.0
julia> accuracy([1,0,0,1,1], [1,-1,-1,-1,1], LabelEnc.FuzzyBinary())
0.8