Title: | k-Means Algorithm with a Majorization-Minimization Method |
---|---|
Description: | A hybrid of the K-means algorithm and a Majorization-Minimization method to introduce a robust clustering. The reference paper is: Julien Mairal, (2015) <doi:10.1137/140957639>. The two most important functions in package 'MajKMeans' are cluster_km() and cluster_MajKm(). cluster_km() clusters data without Majorization-Minimization and cluster_MajKm() clusters data with Majorization-Minimization method. Both of these functions calculate the sum of squares (SS) of clustering. |
Authors: | Sheikhi Ayyub [aut, cre], Yaghoubi Mohammad Ali [aut] |
Maintainer: | Sheikhi Ayyub <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2024-11-07 02:55:28 UTC |
Source: | https://github.com/sheikhi-a/majkmeans |
clusters data into two clusters. This functionis uses the kmeans
function to cluster the data and exports the clustering results as well as the sum of square (SS) of clustering using the Euclidian distance.
clusters_km(x, k = 2)
clusters_km(x, k = 2)
x |
matrix of data (dim 1: samples (must be equal to dim 1 of X), dim 2: attributes (must be equal to dim 2 of X)) |
k |
number of clusters ( this version considers 2 clusters ) |
sum of square (SS) of clustring
{ X=rbind(matrix(rnorm(1000*2 ,4,.1),1000,2),matrix(rnorm(1000*2, 3, 0.2),1000,2)) M <- X[sample(nrow(X), 2),] clusters_km(X,2) }
{ X=rbind(matrix(rnorm(1000*2 ,4,.1),1000,2),matrix(rnorm(1000*2, 3, 0.2),1000,2)) M <- X[sample(nrow(X), 2),] clusters_km(X,2) }
clusters data into two clusters with a majorization k-means This functionis use a hybrid of the k-means and the majorizaion-minimazation method to cluster the data and exports the clustering results as well as the sum of square (SS) of clustering
x |
matrix of data (dim 1: samples (must be equal to dim 1 of X), dim 2: attributes (must be equal to dim 2 of X)) |
k |
number of clusters ( this version considers 2 clusters ) |
La |
the tunnung parameter |
sum of square (SS) of clustring and the 'delta' (difference of two successive majorization function).
{ X=rbind(matrix(rnorm(1000*2 ,4,.1),1000,2),matrix(rnorm(1000*2, 3, 0.2),1000,2)) M <- X[sample(nrow(X), 2),] clusters_MajKm(X,2, 0.5) }
{ X=rbind(matrix(rnorm(1000*2 ,4,.1),1000,2),matrix(rnorm(1000*2, 3, 0.2),1000,2)) M <- X[sample(nrow(X), 2),] clusters_MajKm(X,2, 0.5) }
Calculates the Euclidian distance between points. This function can use in kmeans
function to do the clustering procedure using the Euclidian distance.
Euclid(x, mu)
Euclid(x, mu)
x |
matrix of data (dim 1: samples (must be equal to dim 1 of X), dim 2: attributes (must be equal to dim 2 of X)) |
mu |
initial seleted centroids (randomly or another method). |
Euclidian distance between two points.
{ X=rbind(matrix(rnorm(1000*2 ,4,.1),1000,2),matrix(rnorm(1000*2, 3, 0.2),1000,2)) M <- X[sample(nrow(X), 2),] Euclid(X,M) }
{ X=rbind(matrix(rnorm(1000*2 ,4,.1),1000,2),matrix(rnorm(1000*2, 3, 0.2),1000,2)) M <- X[sample(nrow(X), 2),] Euclid(X,M) }
k-means algorithm in clustering. This function export the clustered results based on one replication of the k-means method
x |
matrix of data (dim 1: samples (must be equal to dim 1 of X), dim 2: attributes (must be equal to dim 2 of X)) |
centers |
initial seleted centroids (randomly or another method) |
distFun |
function (in this package the distance is Euclidian) |
nItter |
Number of itteration function |
clustered results based on k-means methods.
{ X=rbind(matrix(rnorm(1000*2 ,4,.1),1000,2),matrix(rnorm(1000*2, 3, 0.2),1000,2)) M <- X[sample(nrow(X), 2),] kmeans(X,M, Euclid, 4) }
{ X=rbind(matrix(rnorm(1000*2 ,4,.1),1000,2),matrix(rnorm(1000*2, 3, 0.2),1000,2)) M <- X[sample(nrow(X), 2),] kmeans(X,M, Euclid, 4) }