Clustering¶
Learn.jl currently provides only kmeans clustering.
Functions¶
-
fit!{T<:AbstractFloat}(clust::Cluster, X::Matrix{T}) Fit the estimator
clustto the inputsX.Parameters: - clust – The estimator object encapsulating parameters for the estimator. This parameter will be modified by the function. After running
fit!clustwill contain all information required to make predictions. - X – X assumes rows for observations and columns as features.
- clust – The estimator object encapsulating parameters for the estimator. This parameter will be modified by the function. After running
-
predict{T<:AbstractFloat}(clust::Cluster, X::Matrix{T}) Predict values for
Xusing the fitted estimatorclust.Parameters: - clust – The estimator after fitting with
fit!. - X – Input data with observations in rows and features in columns.
- clust – The estimator after fitting with
-
score{T<:AbstractFloat}(clust::Cluster, X::Matrix{T}; scoring::Union{Function, Void}=nothing) Return the score for a set of input observations
Xwith scoring functionscoring.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.
- clust – The estimator trained by
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)