11# Generated by `rjournal_pdf_article()` using `knitr::purl()`: do not edit by hand
22# Please edit RJ-2025-023.Rmd to modify this file
33
4- # # ----setup, include=FALSE-----------------------------------------------------
4+ # # ----setup, include=FALSE---------------------------------------------------------------------------------------------------------------------
55knitr :: opts_chunk $ set(echo = FALSE , warning = FALSE , message = FALSE )
66library(dplyr )
77library(ggplot2 )
@@ -14,28 +14,31 @@ library(theftdlc)
1414knitr :: include_graphics(" figures/workflow-graphic_ecosystem-final.png" )
1515
1616
17- # # ----echo=FALSE---------------------------------------------------------------
17+ # # ----echo=FALSE-------------------------------------------------------------------------------------------------------------------------------
1818temp <- tempfile()
19- download.file(" https://github.com/hendersontrent/bonn-eeg-data/raw/refs/heads/main/INP_Bonn_EEG.txt.zip" ,temp )
19+ download.file(
20+ " https://github.com/hendersontrent/bonn-eeg-data/raw/refs/heads/main/INP_Bonn_EEG.txt.zip" ,
21+ temp
22+ )
2023bonn_eeg <- read.table(unz(temp , " INP_Bonn_EEG.txt" ))
2124unlink(temp )
2225bonn_eeg <- as_tsibble(bonn_eeg , key = c(" id" , " group" ), index = " timepoint" )
2326
2427
25- # # ----message=FALSE, warning=FALSE, eval=FALSE, echo=TRUE----------------------
28+ # # ----message=FALSE, warning=FALSE, eval=FALSE, echo=TRUE--------------------------------------------------------------------------------------
2629# install_python_pkgs(venv = "theft-eco-py", python = "/usr/local/bin/python3.10")
2730# init_theft("theft-eco-py")
2831
2932
30- # # ----message=FALSE, warning=FALSE, eval=FALSE, echo=TRUE----------------------
33+ # # ----message=FALSE, warning=FALSE, eval=FALSE, echo=TRUE--------------------------------------------------------------------------------------
3134# all_features <- calculate_features(
3235# data = bonn_eeg,
3336# feature_set = c("catch22", "feasts", "tsfeatures",
3437# "tsfresh", "tsfel", "kats"),
3538# use_compengine = FALSE, catch24 = TRUE)
3639
3740
38- # # ----message=FALSE, warning=FALSE, eval=FALSE, echo=TRUE----------------------
41+ # # ----message=FALSE, warning=FALSE, eval=FALSE, echo=TRUE--------------------------------------------------------------------------------------
3942# all_features_msd <- calculate_features(
4043# data = bonn_eeg,
4144# feature_set = c("catch22", "feasts", "tsfeatures",
@@ -44,7 +47,7 @@ bonn_eeg <- as_tsibble(bonn_eeg, key = c("id", "group"), index = "timepoint")
4447# use_compengine = FALSE)
4548
4649
47- # # ----echo=TRUE----------------------------------------------------------------
50+ # # ----echo=TRUE--------------------------------------------------------------------------------------------------------------------------------
4851files <- c(" all_features" , " mf_results" , " feature_classifiers" )
4952
5053for (f in files ){
@@ -63,7 +66,7 @@ plot(all_features,
6366 clust_method = " average" )
6467
6568
66- # # ----echo = TRUE, eval = FALSE------------------------------------------------
69+ # # ----echo = TRUE, eval = FALSE----------------------------------------------------------------------------------------------------------------
6770# low_dim_calc <- project(all_features,
6871# method = "MinMax",
6972# low_dim_method = "tSNE",
@@ -82,7 +85,7 @@ plot(low_dim_calc) +
8285 guides(colour = guide_legend(nrow = 2 , byrow = TRUE ))
8386
8487
85- # # ----message=FALSE, warning=FALSE, eval=FALSE, echo=TRUE----------------------
88+ # # ----message=FALSE, warning=FALSE, eval=FALSE, echo=TRUE--------------------------------------------------------------------------------------
8689# mf_results <- classify(
8790# data = all_features,
8891# by_set = TRUE,
@@ -91,7 +94,7 @@ plot(low_dim_calc) +
9194# use_null = TRUE)
9295
9396
94- # # ----message=FALSE, warning=FALSE, eval=FALSE, echo=TRUE----------------------
97+ # # ----message=FALSE, warning=FALSE, eval=FALSE, echo=TRUE--------------------------------------------------------------------------------------
9598# rbfClassifier <- function(formula, data){
9699# mod <- e1071::svm(formula, data = data, kernel = "radial", scale = FALSE,
97100# probability = TRUE)
@@ -106,7 +109,7 @@ plot(low_dim_calc) +
106109# use_null = TRUE)
107110
108111
109- # # ----warning=FALSE, message=FALSE, echo=TRUE, eval=TRUE-----------------------
112+ # # ----warning=FALSE, message=FALSE, echo=TRUE, eval=TRUE---------------------------------------------------------------------------------------
110113set_intervals <- theftdlc :: interval(
111114 mf_results ,
112115 metric = " accuracy" ,
@@ -122,15 +125,15 @@ set_intervals
122125plot(set_intervals )
123126
124127
125- # # ----message=FALSE, warning=FALSE, echo=TRUE, eval=FALSE----------------------
128+ # # ----message=FALSE, warning=FALSE, echo=TRUE, eval=FALSE--------------------------------------------------------------------------------------
126129# compare_features(mf_results,
127130# metric = "accuracy",
128131# by_set = TRUE,
129132# hypothesis = "null",
130133# p_adj = "none")
131134
132135
133- # # ----echo=FALSE, eval=TRUE----------------------------------------------------
136+ # # ----echo=FALSE, eval=TRUE--------------------------------------------------------------------------------------------------------------------
134137knitr :: kable(compare_features(mf_results ,
135138 metric = " accuracy" ,
136139 by_set = TRUE ,
@@ -141,15 +144,15 @@ knitr::kable(compare_features(mf_results,
141144 digits = 3 )
142145
143146
144- # # ----message=FALSE, warning=FALSE, echo=TRUE, eval=FALSE----------------------
147+ # # ----message=FALSE, warning=FALSE, echo=TRUE, eval=FALSE--------------------------------------------------------------------------------------
145148# compare_features(mf_results,
146149# metric = "accuracy",
147150# by_set = TRUE,
148151# hypothesis = "pairwise",
149152# p_adj = "none")
150153
151154
152- # # ----echo=FALSE---------------------------------------------------------------
155+ # # ----echo=FALSE-------------------------------------------------------------------------------------------------------------------------------
153156knitr :: kable(compare_features(mf_results ,
154157 metric = " accuracy" ,
155158 by_set = TRUE ,
@@ -160,32 +163,32 @@ knitr::kable(compare_features(mf_results,
160163 digits = 3 )
161164
162165
163- # # ----message=FALSE, warning=FALSE, eval=FALSE, echo=TRUE----------------------
166+ # # ----message=FALSE, warning=FALSE, eval=FALSE, echo=TRUE--------------------------------------------------------------------------------------
164167# feature_classifiers <- classify(data = all_features,
165168# by_set = FALSE,
166169# train_size = 0.8,
167170# n_resamples = 100,
168171# use_null = TRUE)
169172
170173
171- # # ----message=FALSE, warning=FALSE, echo=TRUE----------------------------------
174+ # # ----message=FALSE, warning=FALSE, echo=TRUE--------------------------------------------------------------------------------------------------
172175feature_vs_null <- compare_features(feature_classifiers ,
173176 by_set = FALSE ,
174177 hypothesis = " null" ,
175178 n_workers = 6 )
176179
177180
178- # # ----message=FALSE, warning=FALSE, echo=TRUE----------------------------------
181+ # # ----message=FALSE, warning=FALSE, echo=TRUE--------------------------------------------------------------------------------------------------
179182top_40 <- feature_vs_null | >
180183 dplyr :: slice_max(feature_mean , n = 40 )
181184
182185
183- # # ----echo=TRUE, eval=FALSE----------------------------------------------------
186+ # # ----echo=TRUE, eval=FALSE--------------------------------------------------------------------------------------------------------------------
184187# top_40 |>
185188# top_n(feature_mean, n = 20)
186189
187190
188- # # ----echo=FALSE---------------------------------------------------------------
191+ # # ----echo=FALSE-------------------------------------------------------------------------------------------------------------------------------
189192if (knitr :: is_html_output()){
190193 knitr :: kable(top_40 | >
191194 dplyr :: select(- c(names , original_names , feature_set , metric )) | >
0 commit comments