forked from mlr-org/mlr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRLearner_classif_plsDA.R
34 lines (31 loc) · 1.18 KB
/
RLearner_classif_plsDA.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
31
32
33
34
# I dont geht this to work, in the case for 2 numeric classes. For multiclass this seems to work
# I dont have time to check the inner problems in the underlying code now
# removed for later
#' @export
makeRLearner.classif.plsDA = function() {
makeRLearnerClassif(
cl = "classif.plsDA",
package = "DiscriMiner",
par.set = makeParamSet(
makeLogicalLearnerParam(id = "autosel", default = TRUE),
makeIntegerLearnerParam(id = "comps", lower = 1L, default = 2L, requires = expression(autosel == TRUE)),
makeLogicalLearnerParam(id = "retain.models", default = FALSE)
),
properties = c("twoclass", "multiclass", "numerics"),
name = "Partial Least Squares (PLS) Discriminant Analysis",
short.name = "plsda",
note = ""
)
}
#' @export
trainLearner.classif.plsDA = function(.learner, .task, .subset, .weights = NULL, ...) {
d = getTaskData(.task, .subset, target.extra = TRUE)
DiscriMiner::plsDA(variables = d$data, group = d$target, ...)
}
#' @export
predictLearner.classif.plsDA = function(.learner, .model, .newdata, ...) {
m = .model$learner.model
p = DiscriMiner::classify(m, newdata = .newdata)
# p$scores #we loose this information
p$pred_class
}