-
-
Notifications
You must be signed in to change notification settings - Fork 404
/
RLearner_classif_quaDA.R
29 lines (27 loc) · 1.04 KB
/
RLearner_classif_quaDA.R
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
#' @export
makeRLearner.classif.quaDA = function() {
makeRLearnerClassif(
cl = "classif.quaDA",
package = "DiscriMiner",
par.set = makeParamSet(
# makeNumericVectorLearnerParam(id = "prior", lower = 0, upper = 1, default = NULL),
makeDiscreteLearnerParam(id = "validation", values = list(crossval = "crossval", learntest = "learntest", NULL = NULL), default = NULL, tunable = FALSE)
),
properties = c("twoclass", "multiclass", "numerics"),
name = "Quadratic Discriminant Analysis",
short.name = "quada",
callees = c("quaDA", "classify")
)
}
#' @export
trainLearner.classif.quaDA = function(.learner, .task, .subset, .weights = NULL, ...) {
d = getTaskData(.task, .subset, target.extra = TRUE, recode.target = "drop.levels")
DiscriMiner::quaDA(variables = d$data, group = d$target, ...)
}
#' @export
predictLearner.classif.quaDA = function(.learner, .model, .newdata, ...) {
m = .model$learner.model
p = DiscriMiner::classify(m, newdata = .newdata)
# p$scores #we loose this information
p$pred_class
}