当前位置:网站首页>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
边栏推荐
- Gaode draws lines according to the track
- Importerror: impossible d'importer le nom « graph» de « graphviz»
- 每月1号开始计算当月工作日
- Multi line display and single line display of tqdm
- Homer forecast motif
- Homer预测motif
- 念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研
- Compilation errors and printout garbled problems caused by Chinese content in vs2019 code
- III Chip startup and clock system
- C# 文件与文件夹操作
猜你喜欢
随机推荐
Compilation errors and printout garbled problems caused by Chinese content in vs2019 code
基于Hardhat编写合约测试用例
Is it safe to open a stock account online? I'm a novice, please guide me
PLC-Recorder快速监控多个PLC位的技巧
C#基于当前时间,获取唯一识别号(ID)的方法
Approximate sum count (approximate
Redis exceeds the maximum memory error oom command not allowed when used memory & gt; ' maxmemory'
ros gazebo相关包的安装
高德根据轨迹画线
Homer forecast motif
MTK full dump grab
Jenkins安装
ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
程序员成长第六篇:如何选择公司?
揭露数据不一致的利器 —— 实时核对系统
Precautions for scalable contract solution based on openzeppelin
Astparser parsing class files with enum enumeration methods
Programmer growth Chapter 6: how to choose a company?
Principe du contrat évolutif - delegatecall
The working day of the month is calculated from the 1st day of each month










