-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeasures.R
More file actions
32 lines (26 loc) · 834 Bytes
/
Measures.R
File metadata and controls
32 lines (26 loc) · 834 Bytes
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
library(measures)
rm(list=ls())
# Mean of squared errors, Root mean squared error, Mean of absolute errors
n = 200
set.seed(123)
truth = rnorm(n)
response = rnorm(n)
MSE(truth, response)
RMSE(truth, response)
MAE(truth, response)
# Area under the curve
truth = as.factor(sample(c(1,0), n, replace = TRUE))
probabilities = runif(n)
response = as.factor(as.numeric(probabilities > 0.5))
positive = 1
negative = 0
AUC(probabilities, truth, negative, positive)
# multiclass AUC
truth = as.factor(sample(c(1,2,3), n, replace = TRUE))
probabilities = matrix(runif(60), n, 3)
probabilities = probabilities/rowSums(probabilities)
colnames(probabilities) = c(1,2,3)
multiclass.AU1U(probabilities, truth)
truth = as.factor(sample(c(1,2,3), n, replace = TRUE))
response = as.factor(sample(c(1,2,3), n, replace = TRUE))
ACC(truth, response)