Statistics
CPPLS.invfreqweights — Function
invfreqweights(samples::AbstractVector)Return normalized inverse-frequency weights for samples. Each observation receives weight 1 / count(samples[i]), and the resulting weights are rescaled to sum to 1.
See also fit
Examples
julia> invfreqweights(["a", "b", "b"]) ≈ [0.5, 0.25, 0.25]
trueCPPLS.intervalize — Function
intervalize(values::AbstractVector{<:Real})Convert a sequence of numeric values into adjacent (lo, hi) intervals by pairing consecutive entries. This is useful for building gamma intervals from a range. If values has length 1, a single (x, x) interval is returned. An empty collection throws an ArgumentError.
See also CPPLSModel, fit
Examples
julia> intervalize(0:0.5:1) == [(0.0, 0.5), (0.5, 1.0)]
trueCPPLS.nmc — Function
CPPLS.nmc(
Y_true_one_hot::AbstractMatrix{<:Integer},
Y_pred_one_hot::AbstractMatrix{<:Integer},
weighted::Bool
) -> Float64Compute the normalized misclassification cost between true and predicted one-hot label matrices. The inputs Y_true_one_hot and Y_pred_one_hot are (n_samples × n_classes) one-hot matrices of identical shape containing the ground-truth and predicted labels, respectively. If weighted is false, the function returns the plain misclassification rate, computed as the mean of the entry-wise inequality indicator. When weighted is true, class weights inversely proportional to class prevalence are applied so that all classes contribute equally. Returns a Float64 between 0 and 1.
See also cv_classification, nestedcv, nestedcvperm
Example
julia> Y_true = [1 0 0; 0 1 0; 0 1 0];
julia> Y_pred = [1 0 0; 0 0 1; 0 1 0];
julia> CPPLS.nmc(Y_true, Y_pred, false) ≈ 0.2222222222222222
true
julia> CPPLS.nmc(Y_true, Y_pred, true) ≈ 0.25
true