-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from EvolEcolGroup/cran_sub
Cran 0.9.3
- Loading branch information
Showing
39 changed files
with
606 additions
and
71 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
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
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
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
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
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
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,35 @@ | ||
#' Obtain and format results produced by tuning functions for ensemble objects | ||
#' | ||
#' Return a tibble of performance metrics for all models. | ||
#' | ||
#' @param x A [`simple_ensemble`] or [`repeat_ensemble`] object | ||
#' @param ... Not currently used. | ||
#' @return A tibble. | ||
#' @details | ||
#' | ||
#' When applied to a ensemble, the metrics that are returned | ||
#' do not contain the actual tuning parameter columns and values (unlike when | ||
#' these collect functions are run on other objects). The reason is that ensembles | ||
#' contain different types of models or models with different tuning | ||
#' parameters. | ||
#' | ||
#' @seealso [tune::collect_metrics()] | ||
#' | ||
#' @examples | ||
#' collect_metrics(lacerta_ensemble) | ||
#' collect_metrics(lacerta_rep_ens) | ||
#' @importFrom tune collect_metrics | ||
#' @export | ||
|
||
collect_metrics.simple_ensemble <- function(x, ...) { | ||
dplyr::bind_rows(x$metrics) | ||
} | ||
|
||
#' @export | ||
#' @rdname collect_metrics.simple_ensemble | ||
collect_metrics.repeat_ensemble <- function(x, ...) { | ||
metric_table <- dplyr::bind_rows(x$metrics, .id = "rep_id") | ||
metric_table$rep_id <- x$rep_id[as.numeric(metric_table$rep_id)] | ||
return(metric_table) | ||
} | ||
|
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
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,22 @@ | ||
#' Warn if some times are outside the range of time steps from a raster | ||
#' | ||
#' This function helps making sure that, when we assign times to time_step | ||
#' layers of a raster, we do not have values which are badly out of range | ||
#' @param times the times of the locations | ||
#' @param time_steps the time steps from the raster | ||
#' @returns NULL return | ||
#' @keywords internal | ||
|
||
out_of_range_warning <- function(times, time_steps){ | ||
time_steps_ordered<-sort(time_steps) | ||
range_minmax <- c(utils::head(time_steps_ordered,n=1)[1]- | ||
(abs(utils::head(time_steps_ordered,n=2)[1]-utils::head(time_steps_ordered,n=2)[2])/2), | ||
utils::tail(time_steps_ordered,n=1)[1] + | ||
(abs(utils::tail(time_steps_ordered,n=2)[1]-utils::tail(time_steps_ordered,n=2)[2])/2)) | ||
if(any(times<range_minmax[1]) | any(times>range_minmax[2])) { | ||
warning("Some dates are out of the range of the available time series.\n", | ||
"They will be assigned to the most extreme time point available, but this\n", | ||
"might not make sense. The potentially problematic dates are:\n", | ||
times[which((times<range_minmax[1]) | (times>range_minmax[2]))]) | ||
} | ||
} |
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
Oops, something went wrong.