idil-tub / KMeansClustering.jl

MIT License
1 stars 0 forks source link

KMeansClustering

Build Status

Code Coverage

Documentation

The KMeansClustering package provides an implementation of the K-means clustering algorithm, allowing for the partitioning of a dataset into k clusters. It includes customizable initialization methods for cluster centers and supports different K-means algorithms.

Installation

You can install KMeansClustering.jl by adding it directly from our GitHub repository. Here are the steps:

  1. Open Julia's REPL (the Julia command-line interface).

  2. Press ] to enter Pkg mode (the prompt should change to pkg>).

  3. Run the following command to add KMeansClustering.jl:

pkg> add https://github.com/idil-tub/KMeansClustering.jl.git
  1. Once installed, you can import the package and start using it.
    using KMeansClustering

Usage

# Generate some sample data
data = rand(2, 100)  # 100 data points in 2 dimensions

# Convert data to an AbstractVector of Vector{Float64}
data_vec = [data[:, i] for i in 1:size(data, 2)]

# Perform k-means clustering
k = 3
max_iter = 100
tol = 0.0001
clusters = KMeans(data_vec, k; max_iter=max_iter, tol=tol)

# Print cluster centers and their members
for (center, members) in clusters
    println("Cluster center: ", center)
    println("Members: ", members)
end