Sync portfolio laboratory source
This commit is contained in:
commit
cb87a03d62
5 changed files with 91 additions and 0 deletions
20
analysis.R
Normal file
20
analysis.R
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Синтетические данные и расчёт метрик для обоих дашбордов.
|
||||
set.seed(2026)
|
||||
class <- rbinom(160, 1, 0.45)
|
||||
inputs <- cbind(rbinom(160, 1, 0.2 + 0.55 * class), rbinom(160, 1, 0.4 + 0.35 * class))
|
||||
patterns <- expand.grid(x = 0:1, y = 0:1)
|
||||
scores <- sapply(0:1, function(label) {
|
||||
selected <- inputs[class == label, , drop = FALSE]
|
||||
rate <- (colSums(selected) + 1) / (nrow(selected) + 2)
|
||||
mean(class == label) * apply(patterns, 1, function(row) prod(dbinom(row, 1, rate)))
|
||||
})
|
||||
result <- data.frame(pattern = paste(patterns$x, patterns$y, sep = "_"),
|
||||
probability = scores[, 2] / rowSums(scores))
|
||||
|
||||
# Проверяет конечность основной метрики перед экспортом.
|
||||
stopifnot(nrow(result) > 1, all(is.finite(result$probability)))
|
||||
if (sys.nframe() == 0L) {
|
||||
arguments <- commandArgs(trailingOnly = TRUE)
|
||||
stopifnot(length(arguments) == 1L)
|
||||
write.csv(result, arguments[1], row.names = FALSE)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue