KNearestCenters

KNearestCenters.KncMethod
Knc(config::KncConfig, X, y::CategoricalArray; verbose=true)
Knc(config::KncConfig,
    input_clusters::ClusteringData,
    train_X::AbstractVector,
    train_y::CategoricalArray;
    verbose=false
)

Creates a Knc classifier using the given configuration and data.

source
KNearestCenters.KncConfigSpaceMethod
KncConfigSpace(;
    kernel::Array=[k_(d_()) for k_ in [DirectKernel, ReluKernel],
                                d_ in [L2Distance, CosineDistance]],                         
    centerselection::AbstractVector=[CentroidSelection(), RandomCenterSelection(), MedoidSelection(), KnnCentroidSelection()],
    k::AbstractVector=[1],
    maxiters::AbstractVector=[1, 3, 10],
    recall::AbstractVector=[1.0],
    ncenters::AbstractVector=[0, 10],
    initial_clusters::AbstractVector=[:fft, :dnet, :rand],
    split_entropy::AbstractVector=[0.3, 0.6, 0.9],
    minimum_elements_per_region::AbstractVector=[1, 3, 5]
)

Creates a configuration space for KncConfig

source
Distances.evaluateMethod
evaluate(kernel::CauchyKernel, a, b, σ::AbstractFloat)::Float64

Creates a Cauchy kernel with the given distance function

source
Distances.evaluateMethod
evaluate(kernel::DirectKernel, a, b, σ::AbstractFloat)::Float64

Creates a Direct kernel with the given distance function

source
Distances.evaluateMethod
evaluate(kernel::GaussianKernel, a, b, σ::AbstractFloat)::Float64

Creates a Gaussian kernel with the given distance function

source
Distances.evaluateMethod
evaluate(kernel::LaplacianKernel, a, b, σ::AbstractFloat)::Float64

Creates a Laplacian kernel with the given distance function

source
Distances.evaluateMethod
evaluate(kernel::ReluKernel, a, b, σ::AbstractFloat)::Float64

Creates a Relu kernel with the given distance function

source
Distances.evaluateMethod
evaluate(kernel::SigmoidKernel, a, b, σ::AbstractFloat)::Float64

Creates a Sigmoid kernel with the given distance function

source
Distances.evaluateMethod
evaluate(kernel::TanhKernel, a, b, σ::AbstractFloat)::Float64

Creates a Tanh kernel with the given distance function

source
KNearestCenters.change_criterionFunction
change_criterion(tol=0.001, window=3)

Creates a fuction that stops the process whenever the maximum distance converges (averaging window far items). The tol parameter defines the tolerance range.

source
KNearestCenters.classification_scoresMethod
classification_scores(gold, predicted)

Computes several scores for the given gold-standard and predictions, namely: precision, recall, and f1 scores, for global and per-class granularity

source
KNearestCenters.f1_scoreMethod
f1_score(gold, predict; weight=:macro)::Float64

It computes the F1 score between the gold dataset and the list of predictions predict

It applies the desired weighting scheme for binary and multiclass problems

  • :macro performs a uniform weigth to each class
  • :weigthed the weight of each class is proportional to its population in gold
  • :micro returns the global F1, without distinguishing among classes
source
KNearestCenters.fun_criterionMethod
fun_criterion(fun::Function)

Creates a stop-criterion function that stops whenever the number of far items reaches $\lceil fun(|database|)\rceil$. Already defined examples:

    sqrt_criterion() = fun_criterion(sqrt)
    log2_criterion() = fun_criterion(log2)
source
KNearestCenters.isqerrorMethod
isqerror(X::AbstractVector{F}, Y::AbstractVector{F}) where {F <: AbstractFloat}

Negative squared error (to be used for maximizing algorithms)

source
KNearestCenters.mean_labelMethod
mean_label(nc::Knc, res::KnnResult)

Summary function that computes the label as the mean of the k nearest labels (ordinal classification)

source
KNearestCenters.most_frequent_labelMethod
most_frequent_label(nc::Knc, res::KnnResult)

Summary function that computes the label as the most frequent label among labels of the k nearest prototypes (categorical labels)

source
KNearestCenters.precision_recallMethod
precision_recall(gold::AbstractVector{T1}, predicted::AbstractVector{T2}) where {T1<:Integer} where {T2<:Integer

Computes the global and per-class precision and recall values between the gold standard and the predicted set

source
KNearestCenters.precision_scoreMethod
precision_score(gold, predict; weight=:macro)::Float64

It computes the precision between the gold dataset and the list of predictions predict

It applies the desired weighting scheme for binary and multiclass problems

  • :macro performs a uniform weigth to each class
  • :weigthed the weight of each class is proportional to its population in gold
  • :micro returns the global precision, without distinguishing among classes
source
KNearestCenters.recall_scoreMethod
recall_score(gold, predict; weight=:macro)::Float64

It computes the recall between the gold dataset and the list of predictions predict

It applies the desired weighting scheme for binary and multiclass problems

  • :macro performs a uniform weigth to each class
  • :weigthed the weight of each class is proportional to its population in gold
  • :micro returns the global recall, without distinguishing among classes
source
KNearestCenters.spearmanMethod
spearman(X::AbstractVector{F}, Y::AbstractVector{F}) where {F <: AbstractFloat}

Spearman rank correleation score

source
KNearestCenters.transformFunction
transform(nc::Knc, kernel::Function, X, normalize!::Function=softmax!)

Maps a collection of objects to the vector space defined by each center in nc; the kernel function is used measure the similarity between each $u \in X$ and each center in nc. The normalization function is applied to each vector (normalization methods needing to know the attribute's distribution can be applied on the output of transform)

source
StatsBase.predictMethod
predict(nc::Knc, x, res::KnnResult)
predict(nc::Knc, x)

Predicts the class of x using the label of the k nearest centers under the kernel function.

source