Clustering

Learn.jl currently provides only kmeans clustering.

Functions

fit!{T<:AbstractFloat}(clust::Cluster, X::Matrix{T})

Fit the estimator clust to the inputs X.

Parameters:
  • clust – The estimator object encapsulating parameters for the estimator. This parameter will be modified by the function. After running fit! clust will contain all information required to make predictions.
  • X – X assumes rows for observations and columns as features.
predict{T<:AbstractFloat}(clust::Cluster, X::Matrix{T})

Predict values for X using the fitted estimator clust.

Parameters:
  • clust – The estimator after fitting with fit!.
  • X – Input data with observations in rows and features in columns.
score{T<:AbstractFloat}(clust::Cluster, X::Matrix{T}; scoring::Union{Function, Void}=nothing)

Return the score for a set of input observations X with scoring function scoring.

Parameters:
  • clust – The estimator trained by fit.
  • X – The input values with observations as rows and features as columns.
  • scoring – Optional scoring function. By default for K-means 1/totalcosts is used.

K-means

Implementation of the K-means algorithm. This code uses Clustering.jl, which in turn wraps LIBSVM.

Kmeans(;n_clusters::Int=8, max_iter::Int=300, n_init::Int=10, init::Symbol=:kmpp, tol::Float64=1e-4)

For detailed information about the parameters refer to the documentation of Clustering.jl.

clust = Kmeans(n_clusters=3)
fit!(clust, X)
predict(clust, X)
score(clust, X_new)