当前位置:网站首页>Cluster Analysis in R Simplified and Enhanced
Cluster Analysis in R Simplified and Enhanced
2022-07-02 09:38:00 【小宇2022】
install.packages("factoextra")
library(factoextra)
# Load and scale the dataset
data("USArrests")
df <- scale(USArrests)
head(df)
library(factoextra)
# Correlation-based distance method
res.dist <- get_dist(df, method = "pearson")
head(round(as.matrix(res.dist), 2))[, 1:6]
# Visualize the dissimilarity matrix
fviz_dist(res.dist, lab_size = 8)
# Load and scale the dataset
data("USArrests")
df <- scale(USArrests)
# Compute dissimilarity matrix
res.dist <- dist(df, method = "euclidean")
# Compute hierarchical clustering
res.hc <- hclust(res.dist, method = "ward.D2")
# Visualize
plot(res.hc, cex = 0.5)
eclust(x, FUNcluster = "kmeans", hc_metric = "euclidean", ...)
library("factoextra")
# Enhanced k-means clustering
res.km <- eclust(df, "kmeans", nstart = 25)
library("factoextra")
# Gap statistic plot
fviz_gap_stat(res.km$gap_stat)
library("factoextra")
# Silhouette plot
fviz_silhouette(res.km)
library("factoextra")
res.hc <- eclust(df, "hclust") # compute hclust
fviz_dend(res.hc, rect = TRUE) # dendrogam
library("factoextra")
fviz_silhouette(res.hc) # silhouette plot
library("factoextra")
fviz_cluster(res.hc) # scatter plot
边栏推荐
猜你喜欢
PKG package manager usage instance in FreeBSD
TIPC addressing 2
Internship report skywalking distributed link tracking?
Summary of data export methods in powerbi
Why does LabVIEW lose precision in floating point numbers
Attribute acquisition method and operation notes of C # multidimensional array
III Chip startup and clock system
Skills of PLC recorder in quickly monitoring multiple PLC bits
PYQT5+openCV项目实战:微循环仪图片、视频记录和人工对比软件(附源码)
Jinshanyun - 2023 Summer Internship
随机推荐
CTF record
Is bond fund safe? Does the bond buying foundation lose principal?
RPA advanced (II) uipath application practice
CentOS8之mysql基本用法
Why does LabVIEW lose precision in floating point numbers
mmrotate旋转目标检测框架使用记录
Rest (XOR) position and thinking
Thanos Receiver
解决uniapp列表快速滑动页面数据空白问题
ros缺少xacro的包
Gaode draws lines according to the track
Regular and common formulas
sql left join 主表限制条件写在on后面和写在where后面的区别
Array splitting (regular thinking
2022年4月17日五心红娘团队收获双份喜报
spritejs
flutter 问题总结
Amazon cloud technology community builder application window opens
bedtools使用教程
vant tabs组件选中第一个下划线位置异常