forked from mlr-org/mlr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRLearner_classif_linDA.R
30 lines (28 loc) · 1.12 KB
/
RLearner_classif_linDA.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
30
#' @export
makeRLearner.classif.linDA = function() {
makeRLearnerClassif(
cl = "classif.linDA",
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 = "Linear Discriminant Analysis",
short.name = "linda",
note = "Set `validation = NULL` by default to disable internal test set validation.",
callees = c("linDA", "classify")
)
}
#' @export
trainLearner.classif.linDA = function(.learner, .task, .subset, .weights = NULL, ...) {
d = getTaskData(.task, .subset, target.extra = TRUE, recode.target = "drop.levels")
DiscriMiner::linDA(variables = d$data, group = d$target, ...)
}
#' @export
predictLearner.classif.linDA = function(.learner, .model, .newdata, ...) {
m = .model$learner.model
p = DiscriMiner::classify(m, newdata = .newdata)
# p$scores #we loose this information
p$pred_class
}