mesmer.weighted.get_weights_density#
- mesmer.weighted.get_weights_density(pred_data)#
generate inverse data-density weights
Generate weights for the each sample, based on the inverse of the density of the predictors. More precisely, the density of the predictors is represented by a multidimensional kernel density estimate using gaussian kernels where each dimension is one of the predictors. Subsequently, the weights are the inverse of this density of the predictors. Consequently, samples in regions of this space with low density will have higher weights, this is, “unusual” samples will have more weight.
- Parameters:
pred_data (xr.DataTree | xr.Dataset | np.array) – Predictors for the training sample. Each node must be a scenario, with a xarray dataset (time, member). Each predictor is a variable.
- Returns:
weights (DataTree) – Weights for the sample, based on the inverse of the density of the predictors, summing to 1.