inverse_frequency_sample_weight#

openstef_models.transforms.general.sample_weighter.inverse_frequency_sample_weight(x: ndarray, n_bins: int = 50, dampening_exponent: float = 0.5, floor: float = 0.1) ndarray[source]#

Calculate sample weights based on inverse frequency using histogram binning.

Values that occur more frequently receive lower weights, while values that occur less frequently (rare samples) receive higher weights.

Parameters:
  • x (ndarray) – Array of target values to compute weights from.

  • n_bins (int) – Number of equal-width histogram bins for frequency estimation.

  • dampening_exponent (float) – Exponent in [0, 1] applied to inverse frequency ratio. Lower values compress the weight range, reducing impact of very rare samples. Use 1.0 for linear (no dampening), 0.0 for uniform weights.

  • floor (float) – Minimum weight value. Ensures all samples contribute to training.

  • x

  • n_bins

  • dampening_exponent

  • floor

Returns:

Array of weights in range [floor, 1.0] with same shape as input.

Return type:

ndarray