@@ -142,7 +142,7 @@ is.jaspMachineLearning <- function(x) {
142
142
as.character(e1071 ::: predict.naiveBayes(model , newdata = dataset , type = " class" ))
143
143
}
144
144
.mlPredictionGetPredictions.glm <- function (model , dataset ) {
145
- # TODO
145
+ as.character(levels(as.factor( model $ model [, 1 ]))[round(predict( model , newdata = dataset , type = " response " ), 0 ) + 1 ])
146
146
}
147
147
.mlPredictionGetPredictions.vglm <- function (model , dataset ) {
148
148
# TODO
@@ -248,7 +248,8 @@ is.jaspMachineLearning <- function(x) {
248
248
return (model )
249
249
}
250
250
.decodeJaspMLobject.glm <- function (model ) {
251
- # TODO
251
+ formula <- formula(paste(decodeColNames(as.character(model $ terms )[2 ]), " ~" , paste0(decodeColNames(strsplit(as.character(model $ terms )[3 ], split = " + " , fixed = TRUE )[[1 ]]), collapse = " + " )))
252
+ model $ terms <- stats :: terms(formula )
252
253
return (model )
253
254
}
254
255
.decodeJaspMLobject.vglm <- function (model ) {
@@ -352,8 +353,6 @@ is.jaspMachineLearning <- function(x) {
352
353
table $ addColumnInfo(name = " mtry" , title = gettext(" Features per split" ), type = " integer" )
353
354
} else if (inherits(model , " cv.glmnet" )) {
354
355
table $ addColumnInfo(name = " lambda" , title = " \u 03BB" , type = " number" )
355
- } else if (inherits(model , " glm" ) || inherits(model , " vglm" )) {
356
- table $ addColumnInfo(name = " family" , title = gettext(" Family" ), type = " string" )
357
356
}
358
357
table $ addColumnInfo(name = " ntrain" , title = gettext(" n(Train)" ), type = " integer" )
359
358
table $ addColumnInfo(name = " nnew" , title = gettext(" n(New)" ), type = " integer" )
@@ -372,10 +371,6 @@ is.jaspMachineLearning <- function(x) {
372
371
row [[" mtry" ]] <- model [[" mtry" ]]
373
372
} else if (inherits(model , " cv.glmnet" )) {
374
373
row [[" lambda" ]] <- model [[" lambda.min" ]]
375
- } else if (inherits(model , " glm" )) {
376
- row [[" family" ]] <- gettext(" binomial" )
377
- } else if (inherits(model , " vglm" )) {
378
- row [[" family" ]] <- gettext(" multinomial" )
379
374
}
380
375
if (length(presentVars ) > 0 ) {
381
376
row [[" nnew" ]] <- nrow(dataset )
0 commit comments