File size: 1,109 Bytes
87c83ab
 
 
 
 
889ab6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87c83ab
889ab6a
 
87c83ab
 
 
 
 
889ab6a
 
87c83ab
 
 
 
 
 
 
 
 
889ab6a
 
87c83ab
 
 
 
 
889ab6a
87c83ab
 
 
 
889ab6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env Rscript
library(optparse)
library(cvms)

option_list <- list(
  make_option(c("--out_path"),
    type = "character",
    help = "Path to save data at."
  ),
  make_option(c("--num_classes"),
    type = "integer",
    help = "Number of classes."
  ),
  make_option(c("--num_observations"),
    type = "integer",
    help = "Number of observations."
  ),
  make_option(c("--seed"),
    type = "integer",
    help = "Number of observations."
  )
)

opt_parser <- OptionParser(option_list = option_list)
opt <- parse_args(opt_parser)

print(opt)

# Set seed if given
if (!is.null(opt$seed)) {
  set.seed(opt$seed)
}

# Make fairly certain predictions
rcertain <- function(n) {
  (runif(n, min = 1, max = 100)^1.4) / 100
}

# Generate data
data <- cvms::multiclass_probability_tibble(
  num_classes = opt$num_classes,
  num_observations = opt$num_observations,
  apply_softmax = TRUE,
  FUN = rcertain,
  class_name = "c",
  add_predicted_classes = TRUE,
  add_targets = TRUE
)

data <- data[, c("Predicted Class", "Target")]

# Write to disk
write.csv(data, file = opt$out_path, row.names = FALSE)