2024-03-08 11:52:55 +01:00
|
|
|
# 11_investigate-variants.R
|
|
|
|
#
|
|
|
|
# content: (1) Read data
|
2024-03-12 17:52:53 +01:00
|
|
|
# (2) Investigate variants
|
2024-03-08 11:52:55 +01:00
|
|
|
#
|
2024-03-12 17:52:53 +01:00
|
|
|
# input: results/haum/eventlogs_pre-corona_case-clusters.RData
|
|
|
|
# output:
|
2024-03-08 11:52:55 +01:00
|
|
|
#
|
2024-03-12 17:52:53 +01:00
|
|
|
# last mod: 2024-03-12
|
2024-03-08 11:52:55 +01:00
|
|
|
|
|
|
|
# setwd("C:/Users/nwickelmaier/Nextcloud/Documents/MDS/2023ss/60100_master_thesis/analysis/code")
|
|
|
|
|
2024-03-12 17:52:53 +01:00
|
|
|
library(bupaverse)
|
|
|
|
|
2024-03-08 11:52:55 +01:00
|
|
|
#--------------- (1) Read data ---------------
|
|
|
|
|
|
|
|
load("results/haum/eventlogs_pre-corona_cleaned.RData")
|
|
|
|
|
2024-03-12 17:52:53 +01:00
|
|
|
#--------------- (2) Investigate variants ---------------
|
2024-03-08 11:52:55 +01:00
|
|
|
|
2024-03-12 17:52:53 +01:00
|
|
|
dat$start <- dat$date.start
|
|
|
|
dat$complete <- dat$date.stop
|
2024-03-08 11:52:55 +01:00
|
|
|
|
2024-03-12 17:52:53 +01:00
|
|
|
alog <- activitylog(dat,
|
2024-03-08 11:52:55 +01:00
|
|
|
case_id = "case",
|
|
|
|
activity_id = "item",
|
|
|
|
resource_id = "path",
|
|
|
|
timestamps = c("start", "complete"))
|
|
|
|
|
2024-03-12 17:52:53 +01:00
|
|
|
pdf("results/figures/freq-traces.pdf", height = 7, width = 6, pointsize = 10)
|
2024-03-08 11:52:55 +01:00
|
|
|
trace_explorer(alog, n_traces = 25)
|
|
|
|
# --> sequences of artworks are just too rare
|
2024-03-12 17:52:53 +01:00
|
|
|
dev.off()
|
|
|
|
|
|
|
|
trace_explorer(alog, n_traces = 10, type = "infrequent")
|
2024-03-08 11:52:55 +01:00
|
|
|
|
|
|
|
tr <- traces(alog)
|
|
|
|
trace_length <- pbapply::pbsapply(strsplit(tr$trace, ","), length)
|
|
|
|
tr[trace_length > 10, ]
|
|
|
|
|
|
|
|
trace_varied <- pbapply::pbsapply(strsplit(tr$trace, ","), function(x) length(unique(x)))
|
|
|
|
tr[trace_varied > 1, ]
|
|
|
|
table(tr[trace_varied > 2, "absolute_frequency"])
|
|
|
|
table(tr[trace_varied > 3, "absolute_frequency"])
|
|
|
|
|
|
|
|
summary(tr$absolute_frequency)
|
|
|
|
vioplot::vioplot(tr$absolute_frequency)
|
|
|
|
|
|
|
|
# Power law for frequencies of traces
|
|
|
|
tab <- table(tr$absolute_frequency)
|
2024-03-15 16:29:50 +01:00
|
|
|
x <- as.numeric(names(tab))
|
|
|
|
y <- as.numeric(tab)
|
2024-03-08 11:52:55 +01:00
|
|
|
|
|
|
|
p1 <- lm(log(y) ~ log(x))
|
|
|
|
pre <- exp(coef(p1)[1]) * x^coef(p1)[2]
|
2024-03-15 16:29:50 +01:00
|
|
|
|
|
|
|
pdf("results/figures/freq-traces_powerlaw.pdf", height = 3.375,
|
|
|
|
width = 3.375, pointsize = 10)
|
|
|
|
par(mai = c(.6,.6,.1,.1), mgp = c(2.4, 1, 0))
|
|
|
|
|
|
|
|
plot(x, y, log = "xy", xlab = "Absolute Frequency of Traces",
|
|
|
|
ylab = "Frequency", pch = 16, col = rgb(0.262, 0.309, 0.309, 0.5))
|
|
|
|
lines(x, pre, col = "#434F4F")
|
|
|
|
legend("topright", paste0("Proportion of traces only occurring once: ",
|
|
|
|
round(tab[1] / nrow(tr), 2)), cex = .7, bty = "n")
|
|
|
|
|
|
|
|
dev.off()
|
2024-03-08 11:52:55 +01:00
|
|
|
|
|
|
|
# Look at individual traces as examples
|
|
|
|
tr[trace_varied == 5 & trace_length > 50, ]
|
|
|
|
# --> every variant exists only once, of course
|
|
|
|
|