param087 / swiftML

Swift library for Machine Learning
Apache License 2.0
59 stars 8 forks source link

Add K-Means clustering #8

Closed param087 closed 4 years ago

param087 commented 4 years ago

KMeans Clustering


KMeans(clusterCount: 2, maximumIterationCount: 300, initializer: "kmean++", seed: 0)

Method for cluster initialization.

"kmeans++": Heuristic Initialization of centroids. "random": Random Initialization of centroids.

API Methods

fit(data: Tensor): Fit a KMeans cluster. prediction(for: Tensor): Predict the closest cluster given sample belongs. score(): Returns the sum of squared distances of samples to their closest cluster center. transformation(for: Tensor): Transform input to a cluster-distance space. fitAndPrediction(for: Tensor): Compute cluster centers and predict the closest cluster given sample belongs. fitAndTransformation(for: Tensor): Compute cluster centers and transform input to a cluster-distance space.

References