当前位置:网站首页>Seriation in R: How to Optimally Order Objects in a Data Matrice
Seriation in R: How to Optimally Order Objects in a Data Matrice
2022-07-02 11:50:00 【Xiaoyu 2022】
library(seriation)
# Load the data
data("iris")
df <- iris
head(df, 2)
# Remove the column `species` (column 5)
df <- df[, -5]
# Reorder the objects randomly
set.seed(123)
df <- df[sample(seq_len(nrow(df))),]
head(df, 2)
# Compute dissimilarity matrix
dist_result <- dist(df)
# Seriate objects, reorder rows based on their similarity
object_order <- seriate(dist_result)
# Extract object orders
head(get_order(object_order), 15)
pimage(dist_result, main = "Random order")

library(seriation)
# Load the data
data("iris")
df <- iris
head(df, 2)
# Remove the column `species` (column 5)
df <- df[, -5]
# Reorder the objects randomly
set.seed(123)
df <- df[sample(seq_len(nrow(df))),]
head(df, 2)
# Compute dissimilarity matrix
dist_result <- dist(df)
# Seriate objects, reorder rows based on their similarity
object_order <- seriate(dist_result)
# Extract object orders
head(get_order(object_order), 15)
pimage(dist_result, order = object_order, main = "Reordered")

library(seriation)
# Data preparation
# Load the dataset
data("USArrests")
# Replace original values by their ranks
df <- head(apply(USArrests, 2, rank), 30)
# Perform seriation on row and columns
row_order <- seriate(dist(df, "minkowski", p = 1), method ="TSP")
col_order <- seriate(dist(t(df), "minkowski", p = 1), method ="TSP")
orders <- c(row_order, col_order)
# Visualization: matrix of bars
# Original matrix
bertinplot(df)

library(seriation)
# Data preparation
# Load the dataset
data("USArrests")
# Replace original values by their ranks
df <- head(apply(USArrests, 2, rank), 30)
# Perform seriation on row and columns
row_order <- seriate(dist(df, "minkowski", p = 1), method ="TSP")
col_order <- seriate(dist(t(df), "minkowski", p = 1), method ="TSP")
orders <- c(row_order, col_order)
# Visualization: matrix of bars
# Original matrix
bertinplot(df, orders)

library(seriation)
# Load demo data
data("Townships")
# Visualize the original data
bertinplot(
Townships,
options = list(panel = panel.circles)
)

library(seriation)
# Load demo data
data("Townships")
# Seriate rows and columns using the bond energy algorithm (BEA)
set.seed(1234)
orders <- seriate(Townships, method = "BEA", control = list(rep = 10))
bertinplot(
Townships, order = orders,
options = list(panel = panel.circles)
)
边栏推荐
猜你喜欢

多文件程序X32dbg动态调试

The computer screen is black for no reason, and the brightness cannot be adjusted.

MySQL linked list data storage query sorting problem

Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?

RPA advanced (II) uipath application practice

Dynamic memory (advanced 4)

GGPlot Examples Best Reference

数字化转型挂帅复产复工,线上线下全融合重建商业逻辑

Webauthn - official development document

TDSQL|就业难?腾讯云数据库微认证来帮你
随机推荐
程序员成长第六篇:如何选择公司?
6方面带你认识LED软膜屏 LED软膜屏尺寸|价格|安装|应用
Esp32 audio frame esp-adf add key peripheral process code tracking
BEAUTIFUL GGPLOT VENN DIAGRAM WITH R
Native method merge word
Never forget, there will be echoes | hanging mirror sincerely invites you to participate in the opensca user award research
[cloud native] 2.5 kubernetes core practice (Part 2)
Power Spectral Density Estimates Using FFT---MATLAB
php 二维、多维 数组打乱顺序,PHP_php打乱数组二维数组多维数组的简单实例,php中的shuffle函数只能打乱一维
mysql 基本语句
What week is a date obtained by QT
Wechat applet uses Baidu API to achieve plant recognition
ESP32存储配网信息+LED显示配网状态+按键清除配网信息(附源码)
JS -- take a number randomly from the array every call, and it cannot be the same as the last time
flutter 问题总结
Is it safe to open a stock account through the QR code of the securities manager? Or is it safe to open an account in a securities company?
Installation of ROS gazebo related packages
MySql存储过程游标遍历结果集
Order by注入
Redis exceeds the maximum memory error oom command not allowed when used memory & gt; ' maxmemory'
