Skip to content

Commit

Permalink
add index used when modelling
Browse files Browse the repository at this point in the history
  • Loading branch information
AparicioJohan committed Jul 10, 2024
1 parent 74e0354 commit 4fc73ef
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 65 deletions.
7 changes: 5 additions & 2 deletions R/06_modeler.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#' @param metric A character string specifying the metric to minimize. Can be "sse", "mae", "mse" or "rmse". Default is "sse".
#' @param n_points Number of time points to approximate the Area Under the Curve (AUC). 1000 by default.
#' @param max_time Maximum time value for calculating the AUC. \code{NULL} by default takes the last time point.
#' @param control A list of control parameters to be passed to the optimization function. e.g. list(maxit = 500)
#' @return An object of class \code{modeler_HTP}, which is a list containing the following elements:
#' \describe{
#' \item{\code{param}}{A data frame containing the optimized parameters and related information.}
Expand Down Expand Up @@ -82,7 +83,8 @@ modeler_HTP <- function(x,
fn = "fn_piwise",
metric = "sse",
n_points = 1000,
max_time = NULL) {
max_time = NULL,
control = list()) {
if (!inherits(x, "read_HTP")) {
stop("The object should be of read_HTP class")
}
Expand Down Expand Up @@ -200,7 +202,8 @@ modeler_HTP <- function(x,
metric = metric,
method = method,
lower = lower,
upper = upper
upper = upper,
control = control
) |>
rownames_to_column(var = "method") |>
rename(sse = value) |>
Expand Down
3 changes: 2 additions & 1 deletion R/utils_S3_methods_print.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
#' print(out)
print.modeler_HTP <- function(x, ...) {
param <- select(x$param, -c(row, range))
trait <- unique(x$dt$trait)
cat("\nCall:\n")
print(x$fn)
cat(paste(trait, "~",deparse(x$fn)), "\n")
cat("\n")
if (nrow(param) < 10) {
cat("Sum of Squares Error:\n")
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ mat <- maturity_HTP(
x = results,
index = "GLI_2",
canopy = "Canopy",
plot_id = c(195, 40)
plot_id = c(195, 40, 20)
)
```

Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ out <- canopy_HTP(x = results, index = "Canopy", plot_id = c(60, 150))
print(out)

Call:
fn_piwise(time, t1, t2, k)
Canopy ~ fn_piwise(time, t1, t2, k)

Sum of Squares Error:
Min. 1st Qu. Median Mean 3rd Qu. Max.
Expand All @@ -134,7 +134,7 @@ Optimization Results `head()`:

Metrics:
Plots Timing Convergence Iterations
2 0.7071 secs 100% 273.5 (plot)
2 0.6357 secs 100% 273.5 (plot)
```

``` r
Expand Down Expand Up @@ -164,7 +164,7 @@ ph_1 <- height_HTP(
print(ph_1)

Call:
fn_exp2_exp(time, t1, t2, alpha, beta)
PH ~ fn_exp2_exp(time, t1, t2, alpha, beta)

Sum of Squares Error:
Min. 1st Qu. Median Mean 3rd Qu. Max.
Expand All @@ -176,8 +176,8 @@ Optimization Results `head()`:
150 W19023-21 62 0.000783 -0.0183 0.00143 33.8 32.9

Metrics:
Plots Timing Convergence Iterations
2 0.826 secs 100% 964.5 (plot)
Plots Timing Convergence Iterations
2 0.8743 secs 100% 964.5 (plot)
```

``` r
Expand Down Expand Up @@ -208,28 +208,29 @@ mat <- maturity_HTP(
x = results,
index = "GLI_2",
canopy = "Canopy",
plot_id = c(195, 40)
plot_id = c(195, 40, 20)
)
```

``` r
print(mat)

Call:
fn_lin_pl_lin2(time, t1, t2, dt, k, beta)
GLI_2 ~ fn_lin_pl_lin2(time, t1, t2, dt, k, beta)

Sum of Squares Error:
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.024e-05 1.768e-04 3.435e-04 3.435e-04 5.101e-04 6.767e-04
6.229e-06 8.233e-06 1.024e-05 2.310e-04 3.435e-04 6.767e-04

Optimization Results `head()`:
plot genotype t1 t2 dt k beta sse auc t3
40 W17043-37 36.9 66.4 13.4 0.369 -0.0106 6.77e-04 16.6 79.9
195 W16219-8 39.6 68.3 25.1 0.323 -0.0100 1.02e-05 16.4 93.3
plot genotype t1 t2 dt k beta sse auc t3
20 W17067-7 35.8 68.5 14.5 0.362 -0.00405 6.23e-06 19.0 83.1
40 W17043-37 36.9 66.4 13.4 0.369 -0.01057 6.77e-04 16.6 79.9
195 W16219-8 39.6 68.3 25.1 0.323 -0.01005 1.02e-05 16.4 93.3

Metrics:
Plots Timing Convergence Iterations
2 0.6512 secs 100% 341 (plot)
Plots Timing Convergence Iterations
3 0.9528 secs 100% 444.33 (plot)
```

``` r
Expand All @@ -240,5 +241,6 @@ plot(mat, plot_id = c(195, 40))

| plot | genotype | row | range | t1 | t2 | dt | k | beta | sse | auc | t3 |
|-----:|:----------|----:|------:|-------:|-------:|-------:|------:|-------:|------:|-------:|-------:|
| 20 | W17067-7 | 6 | 2 | 35.818 | 68.529 | 14.540 | 0.362 | -0.004 | 0.000 | 18.977 | 83.069 |
| 40 | W17043-37 | 12 | 3 | 36.880 | 66.416 | 13.438 | 0.369 | -0.011 | 0.001 | 16.615 | 79.854 |
| 195 | W16219-8 | 13 | 14 | 39.591 | 68.279 | 25.058 | 0.323 | -0.010 | 0.000 | 16.376 | 93.336 |
14 changes: 7 additions & 7 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ articles:
canopy-model: canopy-model.html
height-model: height-model.html
maturity-model: maturity-model.html
last_built: 2024-07-09T19:16Z
last_built: 2024-07-10T02:33Z
urls:
reference: https://apariciojohan.github.io/exploreHTP/reference
article: https://apariciojohan.github.io/exploreHTP/articles
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/canopy_HTP.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions docs/reference/height_HTP.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/reference/maturity_HTP.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4fc73ef

Please sign in to comment.