Sync portfolio laboratory source
This commit is contained in:
commit
5ef4287091
5 changed files with 86 additions and 0 deletions
15
analysis.R
Normal file
15
analysis.R
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Синтетические данные и расчёт метрик для обоих дашбордов.
|
||||
set.seed(2026)
|
||||
group <- rep(1:3, each = 35)
|
||||
points <- scale(cbind(rnorm(105, group * 4, 0.7), rnorm(105, c(0, 4, 0)[group], 0.8)))
|
||||
within <- vapply(1:6, function(k) kmeans(points, k, nstart = 20)$tot.withinss, numeric(1))
|
||||
result <- data.frame(k = 1:6, within_ss = within)
|
||||
stopifnot(all(diff(within) < 0))
|
||||
|
||||
# Проверяет конечность основной метрики перед экспортом.
|
||||
stopifnot(nrow(result) > 1, all(is.finite(result$within_ss)))
|
||||
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