From 7c350e66f717a5de15e403d53e04ee926813c543 Mon Sep 17 00:00:00 2001 From: "Behrus Puladi, MD DMD" <44176896+bpuladi@users.noreply.github.com> Date: Fri, 10 May 2024 19:16:27 +0200 Subject: [PATCH 1/3] Update avNNet.R - Correct the linout parameter Correct the linout parameter for avNNet. This is required for regression. If not set, regression performance metrics will be wrong. --- models/files/avNNet.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/models/files/avNNet.R b/models/files/avNNet.R index 213b19a83..08ba3dc1d 100644 --- a/models/files/avNNet.R +++ b/models/files/avNNet.R @@ -19,7 +19,8 @@ modelInfo <- list(label = "Model Averaged Neural Network", }, fit = function(x, y, wts, param, lev, last, classProbs, ...) { dat <- if(is.data.frame(x)) x else as.data.frame(x, stringsAsFactors = TRUE) - dat$.outcome <- y + dat$.outcome <- y + lt <- ifelse(is.factor(y),FALSE,TRUE) if(!is.null(wts)) { out <- caret::avNNet(.outcome ~ ., data = dat, @@ -27,12 +28,14 @@ modelInfo <- list(label = "Model Averaged Neural Network", size = param$size, decay = param$decay, bag = param$bag, + linout = lt, ...) } else out <- caret::avNNet(.outcome ~ ., data = dat, size = param$size, decay = param$decay, bag = param$bag, + linout = lt, ...) out }, From 0b8cf1b5a688716b2e9a883561da6039da1496ea Mon Sep 17 00:00:00 2001 From: "Behrus Puladi, MD DMD" <44176896+bpuladi@users.noreply.github.com> Date: Fri, 10 May 2024 19:17:48 +0200 Subject: [PATCH 2/3] Update pcaNNet.R - Correct the linout parameter Correct the linout parameter for pcaNNet. This is required for regression. If not set, regression performance metrics will be wrong. --- models/files/pcaNNet.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/models/files/pcaNNet.R b/models/files/pcaNNet.R index 78ea3a6f3..183e1f96f 100644 --- a/models/files/pcaNNet.R +++ b/models/files/pcaNNet.R @@ -18,6 +18,7 @@ modelInfo <- list(label = "Neural Networks with Feature Extraction", fit = function(x, y, wts, param, lev, last, classProbs, ...) { dat <- if(is.data.frame(x)) x else as.data.frame(x, stringsAsFactors = TRUE) dat$.outcome <- y + lt <- ifelse(is.factor(y),FALSE,TRUE) if(!is.null(wts)) { out <- caret::pcaNNet(.outcome ~ ., @@ -25,11 +26,13 @@ modelInfo <- list(label = "Neural Networks with Feature Extraction", weights = wts, size = param$size, decay = param$decay, + linout = lt, ...) } else out <- caret::pcaNNet(.outcome ~ ., data = dat, size = param$size, decay = param$decay, + linout = lt, ...) out }, From 2de0a80b1e4346bbddf1fa1de353cacafcb76da9 Mon Sep 17 00:00:00 2001 From: "Behrus Puladi, MD DMD" <44176896+bpuladi@users.noreply.github.com> Date: Fri, 10 May 2024 19:21:04 +0200 Subject: [PATCH 3/3] Update nnet.R - Correct the linout parameter Correct the linout parameter for nnet. This is required for regression. If not set, regression performance metrics will be wrong. --- models/files/nnet.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/models/files/nnet.R b/models/files/nnet.R index 978a7dece..36a53e4fa 100644 --- a/models/files/nnet.R +++ b/models/files/nnet.R @@ -18,17 +18,20 @@ modelInfo <- list(label = "Neural Network", fit = function(x, y, wts, param, lev, last, classProbs, ...) { dat <- if(is.data.frame(x)) x else as.data.frame(x, stringsAsFactors = TRUE) dat$.outcome <- y + lt <- ifelse(is.factor(y),FALSE,TRUE) if(!is.null(wts)) { out <- nnet::nnet(.outcome ~ ., data = dat, weights = wts, size = param$size, decay = param$decay, + linout = lt, ...) } else out <- nnet::nnet(.outcome ~ ., data = dat, size = param$size, decay = param$decay, + linout = lt, ...) out },