当前位置:网站首页>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 09:38:00 【小宇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)
)
边栏推荐
猜你喜欢
C#多维数组的属性获取方法及操作注意
Redis exceeds the maximum memory error oom command not allowed when used memory & gt; ' maxmemory'
亚马逊云科技 Community Builder 申请窗口开启
TDSQL|就业难?腾讯云数据库微认证来帮你
ESP32存储配网信息+LED显示配网状态+按键清除配网信息(附源码)
Tdsql | difficult employment? Tencent cloud database micro authentication to help you
PowerBI中导出数据方法汇总
预言机链上链下调研
Mmrotate rotation target detection framework usage record
Never forget, there will be echoes | hanging mirror sincerely invites you to participate in the opensca user award research
随机推荐
ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
解决uniapp列表快速滑动页面数据空白问题
sqlite 修改列类型
enumrate的start属性的坑
Order by注入
C#多维数组的属性获取方法及操作注意
TIPC Cluster5
map集合赋值到数据库
Liftover for genome coordinate conversion
vant tabs组件选中第一个下划线位置异常
A white hole formed by antineutrons produced by particle accelerators
SSRF
spritejs
SSRF
CTF record
[idea] use the plug-in to reverse generate code with one click
webauthn——官方开发文档
TIPC Getting Started6
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
ESP32存储配网信息+LED显示配网状态+按键清除配网信息(附源码)