KNearestCenters

KNearestCenters.Knc — Method
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.KncConfigSpace — Method
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.evaluate — Method
evaluate(kernel::CauchyKernel, a, b, σ::AbstractFloat)::Float64

Creates a Cauchy kernel with the given distance function

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

Creates a Direct kernel with the given distance function

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

Creates a Gaussian kernel with the given distance function

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

Creates a Laplacian kernel with the given distance function

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

Creates a Relu kernel with the given distance function

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

Creates a Sigmoid kernel with the given distance function

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

Creates a Tanh kernel with the given distance function

source
KNearestCenters.change_criterion — Function
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_scores — Method
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_score — Method
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_criterion — Method
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.isqerror — Method
isqerror(X::AbstractVector{F}, Y::AbstractVector{F}) where {F <: AbstractFloat}

Negative squared error (to be used for maximizing algorithms)

source
KNearestCenters.mean_label — Method
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_label — Method
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_recall — Method
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_score — Method
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_score — Method
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.spearman — Method
spearman(X::AbstractVector{F}, Y::AbstractVector{F}) where {F <: AbstractFloat}

Spearman rank correleation score

source
KNearestCenters.transform — Function
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.predict — Method
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