-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding files associated with manuscript
- Loading branch information
Showing
67 changed files
with
7,109 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ README.Rmd | |
README_files | ||
.github | ||
cran-comments.md | ||
^inst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
.RData | ||
.Ruserdata | ||
*.DS_Store | ||
*.Rproj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
Package: veesa | ||
Type: Package | ||
Title: VEESA Pipeline for Explainable Machine Learning with Functional Data | ||
Version: 0.1.1 | ||
Version: 0.1.2 | ||
Author: Katherine Goode, J. Derek Tucker | ||
Maintainer: Katherine Goode <[email protected]> | ||
Description: Contains functions that are helpful when applying the VEESA pipeline in R. | ||
Description: Contains functions for applying the VEESA pipeline in R. | ||
License: MIT + file LICENSE | ||
Encoding: UTF-8 | ||
LazyData: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
# veesa 0.1.2 | ||
|
||
- Added shifted peaks data | ||
- Added example code from manuscript | ||
|
||
# veesa 0.1.1 | ||
|
||
- Adjusted title in plot_pc_directions | ||
- Updated code to new version of fdasrvf | ||
|
||
# veesa 0.1.0 | ||
|
||
Initial version of package | ||
Initial version of package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#' "Shifted Peaks" Simulated Dataset | ||
#' | ||
#' A simulated dataset generated for examples in the veesa pipeline manuscript. | ||
#' For the code used to prepare this dataset, see | ||
#' https://github.com/sandialabs/veesa/inst/data-shifted-peaks.md. | ||
#' | ||
#' @format A data.frame. | ||
|
||
"shifted_peaks" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
Shifted Peaks Data | ||
================ | ||
|
||
Load packages: | ||
|
||
``` r | ||
library(dplyr) | ||
library(ggplot2) | ||
library(purrr) | ||
``` | ||
|
||
Specify parameters: | ||
|
||
``` r | ||
z1 = 1; z1_sd = 0.05; a1 = -3; a1_sd = 1 | ||
z2 = 1.25; z2_sd = 0.05; a2 = 3; a2_sd = 1 | ||
``` | ||
|
||
Specify the times: | ||
|
||
``` r | ||
times = seq(-15, 15, length.out = 150) | ||
``` | ||
|
||
Functions: | ||
|
||
``` r | ||
# Function for simulating data | ||
generate_data = function(id, group, t) { | ||
if (group == 1) { | ||
z = rnorm(1, z1, z1_sd) | ||
a = rnorm(1, a1, a1_sd) | ||
} | ||
if (group == 2) { | ||
z = rnorm(1, z2, z2_sd) | ||
a = rnorm(1, a2, a2_sd) | ||
} | ||
y = z * exp((-((t - a)^2)) / 2) | ||
|
||
data.frame(id, group = as.character(group), index = 1:length(t), t, y) | ||
} | ||
|
||
# Function for generating true means | ||
true_mean = function(group, t) { | ||
if (group == 1) { | ||
z = z1 | ||
a = a1 | ||
} | ||
if (group == 2) { | ||
z = z2 | ||
a = a2 | ||
} | ||
y = z * exp((-((t - a)^2)) / 2) | ||
data.frame(group = as.character(group), index = 1:length(t), t, y) | ||
} | ||
``` | ||
|
||
Specify the sample sizes: | ||
|
||
``` r | ||
ntrain = 400 | ||
ntest = 100 | ||
n = ntrain + ntest | ||
``` | ||
|
||
Simulate data: | ||
|
||
``` r | ||
set.seed(20211027) | ||
shifted_peaks <- | ||
map2_df( | ||
.x = 1:n, | ||
.y = c(rep(1:2, each = n / 2)), | ||
.f = generate_data, | ||
t = times | ||
) | ||
``` | ||
|
||
Randomly select ids from the simulated data for the training data: | ||
|
||
``` r | ||
train_ids = sample(unique(shifted_peaks$id), ntrain, F) | ||
``` | ||
|
||
Add training/testing variable: | ||
|
||
``` r | ||
shifted_peaks <- | ||
shifted_peaks |> | ||
mutate(data = ifelse(id %in% train_ids, "Training", "Testing")) |> | ||
select(data, id, group, everything()) |> | ||
mutate(data = forcats::fct_relevel(data, "Training", "Testing")) |> | ||
mutate(group = factor(group)) | ||
``` | ||
|
||
Plot of the data: | ||
|
||
``` r | ||
ggplot(shifted_peaks, aes(x = t, y = y, color = group, group = id)) + | ||
geom_line(alpha = 0.35) + | ||
facet_grid(. ~ data) + | ||
theme_bw() + | ||
scale_color_manual(values = wesanderson::wes_palettes$Royal1[2:1]) + | ||
ylim(0, 1.4) + | ||
guides(color = guide_legend(override.aes = list(alpha = 1))) + | ||
labs( | ||
color = "Group", | ||
title = "Simulated functions", | ||
x = "Time", | ||
y = "y" | ||
) | ||
``` | ||
|
||
![](shifted-peaks_files/figure-commonmark/unnamed-chunk-9-1.png) | ||
|
||
Save the simulated data: | ||
|
||
``` r | ||
save(shifted_peaks, file = "../../data/shifted_peaks.rda") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
--- | ||
title: "Shifted Peaks Data" | ||
format: gfm | ||
--- | ||
|
||
Load packages: | ||
|
||
```{r} | ||
#| message: false | ||
library(dplyr) | ||
library(ggplot2) | ||
library(purrr) | ||
``` | ||
|
||
Specify parameters: | ||
|
||
```{r} | ||
z1 = 1; z1_sd = 0.05; a1 = -3; a1_sd = 1 | ||
z2 = 1.25; z2_sd = 0.05; a2 = 3; a2_sd = 1 | ||
``` | ||
|
||
Specify the times: | ||
|
||
```{r} | ||
times = seq(-15, 15, length.out = 150) | ||
``` | ||
|
||
Functions: | ||
|
||
```{r} | ||
# Function for simulating data | ||
generate_data = function(id, group, t) { | ||
if (group == 1) { | ||
z = rnorm(1, z1, z1_sd) | ||
a = rnorm(1, a1, a1_sd) | ||
} | ||
if (group == 2) { | ||
z = rnorm(1, z2, z2_sd) | ||
a = rnorm(1, a2, a2_sd) | ||
} | ||
y = z * exp((-((t - a)^2)) / 2) | ||
data.frame(id, group = as.character(group), index = 1:length(t), t, y) | ||
} | ||
# Function for generating true means | ||
true_mean = function(group, t) { | ||
if (group == 1) { | ||
z = z1 | ||
a = a1 | ||
} | ||
if (group == 2) { | ||
z = z2 | ||
a = a2 | ||
} | ||
y = z * exp((-((t - a)^2)) / 2) | ||
data.frame(group = as.character(group), index = 1:length(t), t, y) | ||
} | ||
``` | ||
|
||
Specify the sample sizes: | ||
|
||
```{r} | ||
ntrain = 400 | ||
ntest = 100 | ||
n = ntrain + ntest | ||
``` | ||
|
||
Simulate data: | ||
|
||
```{r} | ||
set.seed(20211027) | ||
shifted_peaks <- | ||
map2_df( | ||
.x = 1:n, | ||
.y = c(rep(1:2, each = n / 2)), | ||
.f = generate_data, | ||
t = times | ||
) | ||
``` | ||
|
||
Randomly select ids from the simulated data for the training data: | ||
|
||
```{r} | ||
train_ids = sample(unique(shifted_peaks$id), ntrain, F) | ||
``` | ||
|
||
Add training/testing variable: | ||
|
||
```{r} | ||
shifted_peaks <- | ||
shifted_peaks |> | ||
mutate(data = ifelse(id %in% train_ids, "Training", "Testing")) |> | ||
select(data, id, group, everything()) |> | ||
mutate(data = forcats::fct_relevel(data, "Training", "Testing")) |> | ||
mutate(group = factor(group)) | ||
``` | ||
|
||
Plot of the data: | ||
|
||
```{r} | ||
#| fig-width: 16 | ||
#| fig-height: 4 | ||
ggplot(shifted_peaks, aes(x = t, y = y, color = group, group = id)) + | ||
geom_line(alpha = 0.35) + | ||
facet_grid(. ~ data) + | ||
theme_bw() + | ||
scale_color_manual(values = wesanderson::wes_palettes$Royal1[2:1]) + | ||
ylim(0, 1.4) + | ||
guides(color = guide_legend(override.aes = list(alpha = 1))) + | ||
labs( | ||
color = "Group", | ||
title = "Simulated functions", | ||
x = "Time", | ||
y = "y" | ||
) | ||
``` | ||
|
||
Save the simulated data: | ||
|
||
```{r} | ||
save(shifted_peaks, file = "../../data/shifted_peaks.rda") | ||
``` |
Binary file added
BIN
+272 KB
inst/generate-data/shifted-peaks_files/figure-commonmark/unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.