Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
def f1_loss(y_true:torch.Tensor, y_pred:torch.Tensor, is_training=False) -> torch.Tensor: | |
'''Calculate F1 score. Can work with gpu tensors | |
The original implmentation is written by Michal Haltuf on Kaggle. | |
Returns | |
------- | |
torch.Tensor | |
`ndim` == 1. 0 <= val <= 1 | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
def pop_diff(popA, popB, bin_boundaries=None, num_bins=10): | |
""" | |
Compute difference between two populations using the PSI / IV formula | |
$$\Sigma_{i} (p_i^B - p_i^a)*\ln(\frac{p_i^B}{p_i^A})$$ | |
Note: | |
Counts missing values in a separate bin to test for information and shift. | |
Raises ValueError if popA has no nans but popB does. | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#' Project bed occupancy from admissions | |
#' | |
#' This projects bed occupancy using admission incidence stored as a | |
#' `projections` object, and a distribution of length of stay (los). This is a | |
#' wrapper around `simulate_occupancy`, which essentially applies this function | |
#' to different admission trajectories and collects outputs into a single | |
#' `projections` object. | |
#' | |
#' @param x a `projections` object storing forecast of daily admissions |
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
#' Simulator for projecting bed occupancy | |
#' | |
#' This function predits bed occupancy from admission data (dates, and numbers | |
#' of admissions on these days). Duration of hospitalisation is provided by a | |
#' function returning `integer` values for the number of days in hospital. | |
#' | |
#' @param dates A vector of dates, ideally as `Date` but `integer` should work too. | |
#' | |
#' @param n_admissions An `integer` vector giving the number of admissions | |
#' predicted for each date in `dates`. |