From 1e347ae2ff42f5854a25df13e1106127d0bd50d0 Mon Sep 17 00:00:00 2001 From: Jinhwan Kim Date: Wed, 15 Nov 2023 15:24:25 +0900 Subject: [PATCH] fix: markdown r codeblock "``` {r}" to "``` r" --- README.md | 6 +-- docs/index.html | 119 ++++++++++++++++++++++++++++++----------------- docs/pkgdown.yml | 2 +- docs/search.json | 2 +- 4 files changed, 81 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 751209f..a07b0a7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ devtools::install_github("statgarten/stove") ### 1. Sample Data Import -```{r} +``` r # remotes::install_github("statgarten/datatoys") library(stove) library(datatoys) @@ -39,7 +39,7 @@ cleaned_data <- cleaned_data %>% ### 2. Data split and Define preprocessing -```{r} +``` r target_var <- "TG" train_set_ratio <- 0.7 seed <- 1234 @@ -69,7 +69,7 @@ rec <- stove::prepForCV(data = data_train, ### 3. Modeling -```{r} +``` r # User input mode <- "classification" diff --git a/docs/index.html b/docs/index.html index 008f0d0..f44a3e4 100644 --- a/docs/index.html +++ b/docs/index.html @@ -88,54 +88,88 @@

Example Code

1. Sample Data Import

-

```{r} # remotes::install_github(“statgarten/datatoys”) library(stove) library(datatoys) library(dplyr)

-

set.seed(1234)

-

cleaned_data <- datatoys::bloodTest

-

cleaned_data <- cleaned_data %>% mutate_at(vars(SEX, ANE, IHD, STK), factor) %>% mutate(TG = ifelse(TG < 150, 0, 1)) %>% mutate_at(vars(TG), factor) %>% group_by(TG) %>% sample_n(500) # TG(0):TG(1) = 500:500

-

-### 2. Data split and Define preprocessing
-
-```{r}
-target_var <- "TG"
-train_set_ratio <- 0.7
-seed <- 1234
-formula <- paste0(target_var, " ~ .")
-
-# Split data
-
-split_tmp <- stove::trainTestSplit(data = cleaned_data,
-                                   target = target_var,
-                                   prop = train_set_ratio,
-                                   seed = seed
-                                   )
-
-data_train <- split_tmp[[1]] # train data
-data_test <- split_tmp[[2]] # test data
-data_split <- split_tmp[[3]] # whole data with split information
-
-# Define preprocessing recipe for cross validation
-
-rec <- stove::prepForCV(data = data_train,
-                        formula = formula,
-                        imputation = T,
-                        normalization = T,
-                        seed = seed
-                        )
+
+# remotes::install_github("statgarten/datatoys")
+library(stove)
+library(datatoys)
+library(dplyr)
+
+set.seed(1234)
+
+cleaned_data <- datatoys::bloodTest
+
+cleaned_data <- cleaned_data %>%
+  mutate_at(vars(SEX, ANE, IHD, STK), factor) %>%
+  mutate(TG = ifelse(TG < 150, 0, 1)) %>%
+  mutate_at(vars(TG), factor) %>%
+  group_by(TG) %>%
+  sample_n(500) # TG(0):TG(1) = 500:500
-

3. Modeling +

2. Data split and Define preprocessing

-

```{r} # User input

-

mode <- “classification” algo <- “logisticRegression” # Custom name engine <- “glmnet” # glmnet (default) v <- 2 metric <- “roc_auc” # roc_auc (default), accuracy gridNum <- 5 iter <- 10 seed <- 1234

-
+
+target_var <- "TG"
+train_set_ratio <- 0.7
+seed <- 1234
+formula <- paste0(target_var, " ~ .")
+
+# Split data
+
+split_tmp <- stove::trainTestSplit(data = cleaned_data,
+                                   target = target_var,
+                                   prop = train_set_ratio,
+                                   seed = seed
+                                   )
+
+data_train <- split_tmp[[1]] # train data
+data_test <- split_tmp[[2]] # test data
+data_split <- split_tmp[[3]] # whole data with split information
+
+# Define preprocessing recipe for cross validation
+
+rec <- stove::prepForCV(data = data_train,
+                        formula = formula,
+                        imputation = T,
+                        normalization = T,
+                        seed = seed
+                        )
- -
-

Modeling using logistic regression algorithm -

-

finalized <- stove::logisticRegression( algo = algo, engine = engine, mode = mode, trainingData = data_train, splitedData = data_split, formula = formula, rec = rec, v = v, gridNum = gridNum, iter = iter, metric = metric, seed = seed ) ```

+
+

3. Modeling +

+
+# User input
+
+mode <- "classification"
+algo <- "logisticRegression" # Custom name
+engine <- "glmnet" # glmnet (default)
+v <- 2
+metric <- "roc_auc" # roc_auc (default), accuracy
+gridNum <- 5
+iter <- 10
+seed <- 1234
+
+# Modeling using logistic regression algorithm
+
+finalized <- stove::logisticRegression(
+  algo = algo,
+  engine = engine,
+  mode = mode,
+  trainingData = data_train,
+  splitedData = data_split,
+  formula = formula,
+  rec = rec,
+  v = v,
+  gridNum = gridNum,
+  iter = iter,
+  metric = metric,
+  seed = seed
+)

You can compare several models’ performance and visualize them.
These documents contain the example codes for modeling workflow using stove.

+
+

Recommendation @@ -308,7 +342,6 @@

-