Skip to content

Instantly share code, notes, and snippets.

@sandeshregmi
sandeshregmi / simulate_occupancy.R
Created April 23, 2020 03:31 — forked from thibautjombart/simulate_occupancy.R
Simulator for projecting bed occupancy
#' 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`.
@sandeshregmi
sandeshregmi / project_beds.R
Created April 23, 2020 03:32 — forked from thibautjombart/project_beds.R
Project bed occupancy from admissions
#' 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sandeshregmi
sandeshregmi / R_pubmed_download_authors_affiliations.ipynb
Created January 11, 2021 22:41 — forked from macieksk/R_pubmed_download_authors_affiliations.ipynb
Download authors and their affiliations from Pubmed articles using R packages: RISmed, rentrez
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.
@sandeshregmi
sandeshregmi / psi_iv.py
Created July 7, 2022 00:35 — forked from massiung/psi_iv.py
Population Stability Index and Information Value function
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.
@sandeshregmi
sandeshregmi / TutorialPytorchDataloader.ipynb
Created July 7, 2022 00:42 — forked from SandroLuck/TutorialPytorchDataloader.ipynb
Dataloader and Dataset Tutorial Pytorch Pytorch Lightning
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sandeshregmi
sandeshregmi / f1_score.py
Created August 31, 2022 14:00 — forked from SuperShinyEyes/f1_score.py
F1 score in PyTorch
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
@sandeshregmi
sandeshregmi / rwalk_vector_search_cposc_2023.ipynb
Created November 24, 2023 13:44 — forked from rwalk/rwalk_vector_search_cposc_2023.ipynb
Vector search example using star wars scripts (CPOSC 2023)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.