Title: | A Modern K-Means (MKMeans) Clustering Algorithm |
---|---|
Description: | It's a Modern K-Means clustering algorithm allowing data of any number of dimensions, any initial center, and any number of clusters to expect. |
Authors: | Yarong Yang [aut, cre], Nader Ebrahimi [aut], Yoram Rubin [aut], Jacob Zhang [aut] |
Maintainer: | Yarong Yang <[email protected]> |
License: | GPL-2 |
Version: | 3.1 |
Built: | 2024-12-08 07:13:01 UTC |
Source: | CRAN |
It's a Modern K-Means clustering algorithm allowing data of any number of dimensions, any initial center, and any number of clusters to expect.
Package: | MKMeans |
Type: | Package |
Version: | 3.1 |
Date: | 2024-10-09 |
License: | GPL-2 |
Yarong Yang, Nader Ebrahimi, Yoram Rubin, and Jacob Zhang
Yarong Yang and Jacob Zhang.(2024) MKMeans: A Modern K-Means Clustering Algorithm.
x<-rnorm(20,0,1) y<-rnorm(20,1,1) data.test<-cbind(x,y) Res<-MKMeans(data.test,3,1,iteration=1000,tol=.9,type=1) Ress<-Res names(Ress@Classes[[1]])<-rep("red",length(Res@Classes[[1]])) names(Ress@Classes[[2]])<-rep("blue",length(Res@Classes[[2]])) names(Ress@Classes[[3]])<-rep("green",length(Res@Classes[[3]])) Cols<-names(sort(c(Ress@Classes[[1]],Ress@Classes[[2]],Ress@Classes[[3]]))) plot(x,y,type="p",col=Cols,lwd=2) points(Res@Centers,pch=15,col=c("red","blue","green"))
x<-rnorm(20,0,1) y<-rnorm(20,1,1) data.test<-cbind(x,y) Res<-MKMeans(data.test,3,1,iteration=1000,tol=.9,type=1) Ress<-Res names(Ress@Classes[[1]])<-rep("red",length(Res@Classes[[1]])) names(Ress@Classes[[2]])<-rep("blue",length(Res@Classes[[2]])) names(Ress@Classes[[3]])<-rep("green",length(Res@Classes[[3]])) Cols<-names(sort(c(Ress@Classes[[1]],Ress@Classes[[2]],Ress@Classes[[3]]))) plot(x,y,type="p",col=Cols,lwd=2) points(Res@Centers,pch=15,col=c("red","blue","green"))
It's a function of finding the center of a cluster.
C.f(dat, type)
C.f(dat, type)
dat |
Numeric. A cluster matrix with each row being an observaion. |
type |
Integer. The type of distance between observations. 1 for Euclidean distance. 2 for Manhattan distance. 3 for maximum deviation along dimensions. |
A vector.
Yarong Yang
Yarong Yang and Jacob Zhang.(2024) MKMeans: A Modern K-Means Clustering Algorithm.
x<-rnorm(5,0,1) y<-rnorm(5,1,1) data<-cbind(x,y) Res<-C.f(dat=data,type=1)
x<-rnorm(5,0,1) y<-rnorm(5,1,1) data<-cbind(x,y) Res<-C.f(dat=data,type=1)
It's a function of finding the distance between two observations.
Dist(x,y,type)
Dist(x,y,type)
x |
Numeric. A vector denoting an observation. |
y |
Numeric. A vector denoting an observation. |
type |
Integer. The type of distance between observations. 1 for Euclidean distance. 2 for Manhattan distance. 3 for maximum deviation among dimensions. |
A numeric number.
Yarong Yang
Yarong Yang and Jacob Zhang.(2024) MKMeans: A Modern K-Means Clustering Algorithm.
x<-rnorm(10,0,1) y<-rnorm(10,1,1) z<-rnorm(10,2,1) data<-cbind(x,y,z) Res<-Dist(data[1,],data[2,],type=1)
x<-rnorm(10,0,1) y<-rnorm(10,1,1) z<-rnorm(10,2,1) data<-cbind(x,y,z) Res<-Dist(data[1,],data[2,],type=1)
The function MKMeans return object of class MKMean that contains the number of clusters, the center of each cluster, and the observations in each cluster.
new("MKMean",K=new("numeric"),Centers=new("matrix"),Classes=new("list"),Clusters=new("list"))
K
:An integer being the number of clusters.
Centers
:A numeric matrix with each row being center of a cluster.
Classes
:An integer list showing the original indexes of the observations in each cluster.
Clusters
:A numeric list showing the observations in each cluster.
Yarong Yang
Yarong Yang and Jacob Zhang.(2024) MKMeans: A Modern K-Means Clustering Algorithm.
showClass("MKMean")
showClass("MKMean")
It's a Modern K-Means clustering algorithm allowing data of any number of dimensions, any initial center, and any number of clusters to expect.
MKMeans(data, K, initial, iteration, tol, type)
MKMeans(data, K, initial, iteration, tol, type)
data |
Numeric. An observation matrix with each row being an oberservation. |
K |
Integer. The number of clusters expected. |
initial |
Numeric. Either the selected initial center matrix with each row being an observation, or 1 for the first K rows of the data matrix being the intial center. |
iteration |
Integer. The number of the most iterations wanted for the clustering process. |
tol |
Numeric. The minimum acceptable percentage of stable observations to stop the clustering process, basically greater than 0.5 to guarantee the value of the results. |
type |
Integer. The type of distance between observations. 1 for Euclidean distance. 2 for Manhattan distance. 3 for maximum deviation among dimensions. |
An object of class MKMean.
Yarong Yang
Yarong Yang and Jacob Zhang.(2024) MKMeans: A Modern K-Means Clustering Algorithm.
x<-rnorm(20,0,1) y<-rnorm(20,1,1) data.test<-cbind(x,y) Res<-MKMeans(data.test,3,1,iteration=1000,tol=.95,type=1) Ress<-Res names(Ress@Classes[[1]])<-rep("red",length(Res@Classes[[1]])) names(Ress@Classes[[2]])<-rep("blue",length(Res@Classes[[2]])) names(Ress@Classes[[3]])<-rep("green",length(Res@Classes[[3]])) Cols<-names(sort(c(Ress@Classes[[1]],Ress@Classes[[2]],Ress@Classes[[3]]))) plot(x,y,type="p",col=Cols,lwd=2) points(Res@Centers,pch=15,col=c("red","blue","green"))
x<-rnorm(20,0,1) y<-rnorm(20,1,1) data.test<-cbind(x,y) Res<-MKMeans(data.test,3,1,iteration=1000,tol=.95,type=1) Ress<-Res names(Ress@Classes[[1]])<-rep("red",length(Res@Classes[[1]])) names(Ress@Classes[[2]])<-rep("blue",length(Res@Classes[[2]])) names(Ress@Classes[[3]])<-rep("green",length(Res@Classes[[3]])) Cols<-names(sort(c(Ress@Classes[[1]],Ress@Classes[[2]],Ress@Classes[[3]]))) plot(x,y,type="p",col=Cols,lwd=2) points(Res@Centers,pch=15,col=c("red","blue","green"))