Skip to content

Commit

Permalink
fix: default value with ml model
Browse files Browse the repository at this point in the history
close #77
  • Loading branch information
jhk0530 committed Oct 10, 2023
1 parent e9f7770 commit 7ec4c38
Showing 1 changed file with 73 additions and 40 deletions.
113 changes: 73 additions & 40 deletions R/mod_modelingModule.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ mod_modelingModule_server <- function(id, splitresult, models_list, tuned_result
formula = splitresult()$formula, ## Confirmed
rec = splitresult()$rec,
v = ifelse(is.null(input$fold), 2, input$fold),
gridNum = input$gridNum,
iter = input$iter,
metric = input$metric,
seed = input$seed
gridNum = ifelse(is.null(input$gridNum), 5, input$gridNum), #
iter = ifelse(is.null(input$iter), 10, input$iter), #
metric = ifelse(is.null(input$metric), "roc_auc", input$metric),
seed = ifelse(is.null(input$seed), 1234, input$seed) #
)

# Obj <- Obj$finalFittedModel
Expand All @@ -322,8 +322,8 @@ mod_modelingModule_server <- function(id, splitresult, models_list, tuned_result
formula = splitresult()$formula,
rec = splitresult()$rec,
v = ifelse(is.null(input$fold), 2, input$fold),
gridNum = ifelse(is.null(input$gridNum), 4, input$gridNum), #
iter = ifelse(is.null(input$iter), 2, input$iter), #
gridNum = ifelse(is.null(input$gridNum), 5, input$gridNum), #
iter = ifelse(is.null(input$iter), 10, input$iter), #
metric = ifelse(is.null(input$metric), "rmse", input$metric),
seed = ifelse(is.null(input$seed), 1234, input$seed) #
)
Expand Down Expand Up @@ -353,9 +353,9 @@ mod_modelingModule_server <- function(id, splitresult, models_list, tuned_result
formula = splitresult()$formula,
rec = splitresult()$rec,
v = ifelse(is.null(input$fold), 2, input$fold),
gridNum = ifelse(is.null(input$gridNum), 4, input$gridNum), #
iter = ifelse(is.null(input$iter), 2, input$iter), #
metric = ifelse(is.null(input$metric), "rmse", input$metric),
gridNum = ifelse(is.null(input$gridNum), 5, input$gridNum), #
iter = ifelse(is.null(input$iter), 10, input$iter), #
metric = ifelse(is.null(input$metric), ifelse(input$mode == "classification", "roc_auc", "rmse"), input$metric),
seed = ifelse(is.null(input$seed), 1234, input$seed) #
)

Expand Down Expand Up @@ -384,11 +384,11 @@ mod_modelingModule_server <- function(id, splitresult, models_list, tuned_result
splitedData = splitresult()$dataSplit,
formula = splitresult()$formula,
rec = splitresult()$rec,
v = input$fold,
gridNum = input$gridNum,
iter = input$iter,
metric = input$metric,
seed = input$seed
v = ifelse(is.null(input$fold), 2, input$fold),
gridNum = ifelse(is.null(input$gridNum), 5, input$gridNum), #
iter = ifelse(is.null(input$iter), 10, input$iter), #
metric = ifelse(is.null(input$metric), "roc_auc", input$metric),
seed = ifelse(is.null(input$seed), 1234, input$seed) #
)

# Obj <- Obj$finalFittedModel
Expand All @@ -412,11 +412,11 @@ mod_modelingModule_server <- function(id, splitresult, models_list, tuned_result
splitedData = splitresult()$dataSplit,
formula = splitresult()$formula,
rec = splitresult()$rec,
v = input$fold,
gridNum = input$gridNum,
iter = input$iter,
metric = input$metric,
seed = input$seed
v = ifelse(is.null(input$fold), 2, input$fold),
gridNum = ifelse(is.null(input$gridNum), 5, input$gridNum), #
iter = ifelse(is.null(input$iter), 10, input$iter), #
metric = ifelse(is.null(input$metric), ifelse(input$mode == "classification", "roc_auc", "rmse"), input$metric),
seed = ifelse(is.null(input$seed), 1234, input$seed) #
)

Obj
Expand Down Expand Up @@ -444,11 +444,11 @@ mod_modelingModule_server <- function(id, splitresult, models_list, tuned_result
splitedData = splitresult()$dataSplit,
formula = splitresult()$formula,
rec = splitresult()$rec,
v = input$fold,
gridNum = input$gridNum, #
iter = input$iter, #
metric = input$metric,
seed = input$seed
v = ifelse(is.null(input$fold), 2, input$fold),
gridNum = ifelse(is.null(input$gridNum), 5, input$gridNum), #
iter = ifelse(is.null(input$iter), 10, input$iter), #
metric = ifelse(is.null(input$metric), ifelse(input$mode == "classification", "roc_auc", "rmse"), input$metric),
seed = ifelse(is.null(input$seed), 1234, input$seed) #
)

Obj
Expand Down Expand Up @@ -476,11 +476,11 @@ mod_modelingModule_server <- function(id, splitresult, models_list, tuned_result
splitedData = splitresult()$dataSplit,
formula = splitresult()$formula,
rec = splitresult()$rec,
v = input$fold,
gridNum = input$gridNum,
iter = input$iter,
metric = input$metric,
seed = input$seed
v = ifelse(is.null(input$fold), 2, input$fold),
gridNum = ifelse(is.null(input$gridNum), 5, input$gridNum), #
iter = ifelse(is.null(input$iter), 10, input$iter), #
metric = ifelse(is.null(input$metric), ifelse(input$mode == "classification", "roc_auc", "rmse"), input$metric),
seed = ifelse(is.null(input$seed), 1234, input$seed) #
)

Obj
Expand Down Expand Up @@ -508,11 +508,11 @@ mod_modelingModule_server <- function(id, splitresult, models_list, tuned_result
splitedData = splitresult()$dataSplit,
formula = splitresult()$formula,
rec = splitresult()$rec,
v = input$fold,
gridNum = input$gridNum, #
iter = input$iter, #
metric = input$metric,
seed = input$seed #
v = ifelse(is.null(input$fold), 2, input$fold),
gridNum = ifelse(is.null(input$gridNum), 5, input$gridNum), #
iter = ifelse(is.null(input$iter), 10, input$iter), #
metric = ifelse(is.null(input$metric), ifelse(input$mode == "classification", "roc_auc", "rmse"), input$metric),
seed = ifelse(is.null(input$seed), 1234, input$seed) #
)

Obj
Expand Down Expand Up @@ -540,11 +540,11 @@ mod_modelingModule_server <- function(id, splitresult, models_list, tuned_result
splitedData = splitresult()$dataSplit,
formula = splitresult()$formula,
rec = splitresult()$rec,
v = input$fold,
gridNum = input$gridNum,
iter = input$iter,
metric = input$metric,
seed = input$seed
v = ifelse(is.null(input$fold), 2, input$fold),
gridNum = ifelse(is.null(input$gridNum), 5, input$gridNum), #
iter = ifelse(is.null(input$iter), 10, input$iter), #
metric = ifelse(is.null(input$metric), ifelse(input$mode == "classification", "roc_auc", "rmse"), input$metric),
seed = ifelse(is.null(input$seed), 1234, input$seed) #
)

Obj
Expand All @@ -562,6 +562,31 @@ mod_modelingModule_server <- function(id, splitresult, models_list, tuned_result
)
}

if (input$algo == "SVM_linear") {
modelObj <- reactive({
Obj <- stove::SVMLinear(
algo = input$algo,
engine = input$engine,
mode = input$mode,
trainingData = splitresult()$train,
splitedData = splitresult()$dataSplit,
formula = splitresult()$formula,
rec = splitresult()$rec,
v = ifelse(is.null(input$fold), 2, input$fold),
gridNum = ifelse(is.null(input$gridNum), 5, input$gridNum), #
iter = ifelse(is.null(input$iter), 10, input$iter), #
metric = ifelse(is.null(input$metric), "roc_auc", input$metric),
seed = ifelse(is.null(input$seed), 1234, input$seed) #
)

Obj$finalized$finalFittedModel
})

models_list(
append(models_list(), list("svmLinear_kernlab" = modelObj()))
)
}

if (input$algo == "KMC") {
data <- rbind(splitresult()$train, splitresult()$test)

Expand Down Expand Up @@ -694,7 +719,8 @@ mod_modelingModule_server <- function(id, splitresult, models_list, tuned_result
"Decision Tree" = "decisionTree",
"Random Forest" = "randomForest",
"XGBoost",
"lightGBM"
"lightGBM",
"SVM - linear" = "SVM_linear"
),
selected = NULL
)
Expand Down Expand Up @@ -820,6 +846,13 @@ mod_modelingModule_server <- function(id, splitresult, models_list, tuned_result
choices = "-" # KMC
)
}
if (input$algo == "SVM_linear") {
updateSelectInput(
inputId = "engine",
label = "engine 지정",
choices = "kernlab" # svm-linear
)
}
})

return(list(models_list = models_list, tuned_results_list = tuned_results_list))
Expand Down

0 comments on commit 7ec4c38

Please sign in to comment.