Ranges#

scale_method(valid: ndarray, method: str) float[source]#

Compute the scaling span for a 1D array of valid (non-NaN) values.

Parameters:
  • valid (np.ndarray) – 1D array of floats (no NaNs).

  • method (str) – ‘range’ or ‘iqr’.

Returns:

  • span: max-min for ‘range’, Q3-Q1 for ‘iqr’, or 0.0 if constant/empty.

Return type:

float

Raises:

ValueError – if method is unknown.

get_numeric_ranges(X: ndarray, indices: list[int], method: str = 'range') ndarray[source]#

Compute the range for each numeric column in X based on selected scale method. Applied only to ratio-scale and internal-scale data types.

Parameters:
  • X (float) – array of shape (n_samples, n_features).

  • indices (list[int]) – list of column indices to treat as numeric.

  • method (str) – method for scaling, either ‘range’ or ‘iqr’.

Returns:

  • 1D array of length len(indices), where each entry is max(X[:, idx]) - min(X[:, idx]). For now we ignore NaNs. If all values are NaN or constant, range is set to 0.0.

Return type:

np.ndarray