MHCXGraph.utils.tools.value_to_class

MHCXGraph.utils.tools.value_to_class(value: float, bin_width: float, threshold: float, diff_threshold: float, inverse: bool = False, upper_bound: float = 100.0, close_tolerance: float = 0.1) int | list[int] | None[source]

Assign a numeric value to one or more discretized bins.

Parameters:
  • value (float) – Numeric value to classify.

  • bin_width (float) – Width of each bin interval.

  • threshold (float) – Boundary separating lower and upper classification domains.

  • inverse (bool, default=False) – If True, classification occurs in the range [threshold, upper_bound].

  • upper_bound (float, default=100.0) – Maximum allowed value in inverse classification mode.

  • close_tolerance (float, default=0.1) – Absolute tolerance used to detect values close to bin centers.

Returns:

classes – Bin index or indices representing the classification result. Returns None if the value lies outside the allowed domain.

Return type:

int or list[int] or None