Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
5c74b60
re-added testing files inst/examples
Jan 25, 2023
2d4fc8f
add option for linear regression.
Jan 26, 2023
c625b8f
add principal comp. markdown document
Jan 27, 2023
245dbf0
more pca plots
Jan 31, 2023
975a8f1
added principal component analysis
Feb 8, 2023
71234b6
start mlr3 workflow document
Feb 9, 2023
a2e7bee
more mlr3 workflow
julober Feb 11, 2023
72ff1c1
added benchmark, code to predict full raster
julober Feb 16, 2023
8873c7f
start resampling methods document
julober Feb 22, 2023
f99e947
added blockcv example
julober Feb 23, 2023
ea185b0
added script for assembling model input dataframe
julober Feb 27, 2023
d3830bc
added some resampling methods for comparison
julober Feb 27, 2023
a3f7d67
added map of sample points.
julober Feb 28, 2023
ae3d1b4
select dispersed negative sample points
julober Mar 1, 2023
85968a1
refining map
julober Mar 1, 2023
283111a
updating to new data location
julober Mar 6, 2023
8e4555f
exploring feature selection and filtering methods
julober Mar 6, 2023
aacfb87
new workflow document
julober Mar 6, 2023
56b7f86
minor changes
julober Mar 6, 2023
8d9ad32
add forward feature selection
julober Mar 8, 2023
e4eb84b
pre-pipeline save
julober Mar 10, 2023
72cad7b
added pipeline for comparing models
julober Mar 13, 2023
d59a2ab
added final model training steps
julober Mar 22, 2023
286207b
initiation model document first commit
julober Apr 5, 2023
55e2e9a
add feature distribution plots
julober Apr 5, 2023
1e85f3b
add histograms to feature distribution plots
julober Apr 5, 2023
e544004
added some text
julober Apr 5, 2023
efceaa8
assembling data for prediction
julober Apr 13, 2023
2e3bb29
finished code to predict on small basin
julober Apr 14, 2023
f14d1ac
finish success rate curve and generate initial graphs
julober Apr 19, 2023
92e55a8
adding observed landslides to figures
julober Apr 19, 2023
0a98b1f
added origin point to observed landslide curve
julober Apr 20, 2023
7012031
add loop for calculating success rate curve from multiple dems
julober Apr 21, 2023
e3b1b19
multiple basin success rate curve - added observed landslide curve
julober May 1, 2023
810d3a0
re-added testing files inst/examples
Jan 25, 2023
e76efd7
add option for linear regression.
Jan 26, 2023
83df182
add principal comp. markdown document
Jan 27, 2023
c5c37a1
more pca plots
Jan 31, 2023
dda7aad
added principal component analysis
Feb 8, 2023
f785116
start mlr3 workflow document
Feb 9, 2023
dff16ea
more mlr3 workflow
julober Feb 11, 2023
d6128f8
added benchmark, code to predict full raster
julober Feb 16, 2023
26eba1b
start resampling methods document
julober Feb 22, 2023
b9f49ec
added blockcv example
julober Feb 23, 2023
9170012
added script for assembling model input dataframe
julober Feb 27, 2023
fb015b6
added some resampling methods for comparison
julober Feb 27, 2023
c213602
added map of sample points.
julober Feb 28, 2023
e317c67
select dispersed negative sample points
julober Mar 1, 2023
c25418d
refining map
julober Mar 1, 2023
bca9dc6
updating to new data location
julober Mar 6, 2023
c920e07
exploring feature selection and filtering methods
julober Mar 6, 2023
02e7822
new workflow document
julober Mar 6, 2023
902c38e
minor changes
julober Mar 6, 2023
295f2d6
add forward feature selection
julober Mar 8, 2023
35105cd
pre-pipeline save
julober Mar 10, 2023
5b66c0f
added pipeline for comparing models
julober Mar 13, 2023
0dd5898
added final model training steps
julober Mar 22, 2023
d139967
initiation model document first commit
julober Apr 5, 2023
93d4f6f
add feature distribution plots
julober Apr 5, 2023
7c0434a
add histograms to feature distribution plots
julober Apr 5, 2023
91b667e
added some text
julober Apr 5, 2023
f40358e
assembling data for prediction
julober Apr 13, 2023
0ac4875
finished code to predict on small basin
julober Apr 14, 2023
79e86e8
finish success rate curve and generate initial graphs
julober Apr 19, 2023
f48e1df
adding observed landslides to figures
julober Apr 19, 2023
c34d9ff
added origin point to observed landslide curve
julober Apr 20, 2023
006ac4d
add loop for calculating success rate curve from multiple dems
julober Apr 21, 2023
54ca87c
multiple basin success rate curve - added observed landslide curve
julober May 1, 2023
42eda4d
Merge remote-tracking branch 'origin/add_lregmodel_JL' into add_lregm…
julober May 3, 2023
ead2fd1
working on initiation documentation
julober May 5, 2023
2c0b90e
updates to documentation files
julober May 6, 2023
fb697bd
update for success rate curve with all basins
julober May 9, 2023
cacb0a4
add oregon_map file to inst/extdata
julober May 15, 2023
47fc7d6
lastest update of PFA documentation
julober May 18, 2023
35a6f4f
saving some minor file changes
julober Jun 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
Package: TerrainWorksUtils
Type: Package
Title: General utility functions for TerrainWorks
Version: 0.1.3
Authors@R:
c(
person("Helen", "Miller", email = "helenthehuman@gmail.com", role = c("aut", "cre")),
person("Tate", "Brasel", role = "aut")
)
Description: TerrainWorks resources for creating and assessing statistical models for predicting landslide susceptibility.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Imports:
methods,
randomForest,
ROCR,
stats,
terra (>= 1.5)
RoxygenNote: 7.2.3
Suggests:
knitr,
covr,
testthat (>= 3.0.0),
rmarkdown
Config/testthat/edition: 3
VignetteBuilder: knitr
Package: TerrainWorksUtils
Type: Package
Title: General utility functions for TerrainWorks
Version: 0.1.3
Authors@R:
c(
person("Helen", "Miller", email = "helenthehuman@gmail.com", role = c("aut", "cre")),
person("Tate", "Brasel", role = "aut")
)
Description: TerrainWorks resources for creating and assessing statistical models for predicting landslide susceptibility.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Imports:
methods,
randomForest,
caret,
ROCR,
stats,
terra (>= 1.5)
RoxygenNote: 7.2.3
Suggests:
knitr,
covr,
testthat (>= 3.0.0),
rmarkdown
Config/testthat/edition: 3
VignetteBuilder: knitr
10 changes: 7 additions & 3 deletions R/build_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
#' @return Nothing
#' @export
#'
build_k_fold_rf_model <- function(data,
build_k_fold_model <- function(data,
type,
seed = NULL,
ctrl_method = "repeatedcv",
folds = 5,
Expand All @@ -44,6 +45,10 @@ build_k_fold_rf_model <- function(data,
stop("Must provide data.")
}

if (!type %in% c("rf", "glm")) {
stop("Must specify model type. Current options are: rf, glm")
}

if (!is.data.frame(data) | is.null(data$class)) {
stop("Data must be a data frame (or coercible) with a \"class\" column")
}
Expand All @@ -68,7 +73,7 @@ build_k_fold_rf_model <- function(data,
data = data,
preProcess = preprocess,
trControl = ctrl,
method = "rf",
method = type,
metric = "AUC"))

print(model)
Expand All @@ -80,7 +85,6 @@ build_k_fold_rf_model <- function(data,
}



#' @title Build Random Forest Model
#'
#' @param data A dataframe containing columns with model inputs and a
Expand Down
35 changes: 35 additions & 0 deletions R/create_model_dataframe.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# define where to find the data and load it.
folder <- "//Mac/Home/Documents/terrainworks/code/sandbox/data/downloaded_3.6/out/"
folder <- "/Users/julialober/Documents/terrainworks/code/sandbox/data/downloaded_3.6/out/"
load(paste0(folder, "ls_1996.Rdata"))
load(paste0(folder, "ls_2007.Rdata"))
load(paste0(folder, "ls_2011.Rdata"))
load(paste0(folder, "nonls_1996.Rdata"))
load(paste0(folder, "nonls_2007.Rdata"))
load(paste0(folder, "nonls_2011.Rdata"))

# remove these lines when the bug is fixed. the $geo field in the 2011 and 2007
# data frames is not stored as an integer value
ls_2011$geo <- ls_2011$geo$GeoClass
ls_2007$geo <- ls_2007$geo$GeoClass

# add year labels to each selection of landslide points and non-ls points
ls_1996$year <- rep(1996, length(ls_1996[, 1]))
ls_2007$year <- rep(2007, length(ls_2007[, 1]))
ls_2011$year <- rep(2011, length(ls_2011[, 1]))
nonls_1996$year <- rep(1996, length(nonls_1996[, 1]))
nonls_2007$year <- rep(2007, length(nonls_2007[, 1]))
nonls_2011$year <- rep(2011, length(nonls_2011[, 1]))

# combine into one data frame.
subset96 <- seq(1, length(nonls_1996[,1]), 10) # 1:length(ls_1996[, 1])
subset07 <- seq(1, length(nonls_2007[,1]), 10) # 1:length(ls_2007[, 1])
subset11 <- seq(1, length(nonls_2011[,1]), 10) # 1:length(ls_2011[, 1])
training_data <- rbind(ls_1996,
ls_2007,
ls_2011,
nonls_1996[subset96, ],
nonls_2007[subset07, ],
nonls_2011[subset11, ])

training_data$class <- as.factor(training_data$class)
Loading