What it Kmeans?
The answer is herehttp://pengolahancitra.com/index.php?option=com_content&task=view&id=36&Itemid=26
Please later you read for yourself ..
because this directly to the source code wrote:
1.) Open R Studio
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGVUJgDglctGCmHWvSRGwgwmvC7Jk1Wd0SH-oY7AxOJMfoFkBuA1AIMqKW_7IIAlAKN4eBWX92_71chv_kG1Uhrla1Rh793mQIi4vF1_9Fy49jXQz8If_V8UrOq1VE3Vtmx7ix1ObHGrw/s320/image001.png)
2.) Type Source code below:
> require (MASS)
> X <- mvrnorm (n=100, mu=c(5,5),Sigma=matrix(c(1/2,0,0,1/2),nrow=2,ncol=2))
> Y <- mvrnorm (n=100, mu=c(7.5,8),Sigma=matrix(c(1/2,0,0,1/2),nrow=2,ncol=2))
> Z <- mvrnorm (n=100, mu=c(8,5),Sigma=matrix(c(1/2,0,0,1/2),nrow=2,ncol=2))
> data <- rbind (X,Y,Z)
> plot(data)
> kmeans.res <- kmeans (data,centers=3)
> plot(data, col=kmeans.res$cluster)
> points(kmeans.res$centers, cex=2, col=11, pch=19)
> points (matrix (colMeans(data),nrow=1, ncol=2), cex=3, col=12, pch=19)
> kmeans.res$totss
> kmeans.res$betweenss
> kmeans.res$withinss
> kmeans.res$tot.withinss
And the results of the program like this:
Good luck !!!
For the R programming language when calling a function and press entermisalnya > require (MASS) enter
> X <- mvrnorm (n=100, mu=c(5,5),Sigma=matrix(c(1/2,0,0,1/2),nrow=2,ncol=2))
enter
and so on
such as calling in matlab command window also use the enter
<> It is simple for those of you who want to develop please !!!!!
Ganbattee !!!!!!!
.
No comments:
Post a Comment