Categorical ordinal#

categorical_ordinal_component(X: ndarray, Y: ndarray, ordinal_indices: list[int], metadata: dict[int | str, dict[str, Any]], missing_strategy: str = 'ignore', calculation_type: str = 'kaufman', weights: ndarray | None = None) tuple[ndarray, ndarray][source]#

Compute the ordinal categorical component of Gower metric between rows of X and Y.

Parameters:
  • X (np.ndarray) – First dataset, shape (n_x, n_features).

  • Y (np.ndarray) – Second dataset, shape (n_y, n_features).

  • ordinal_indices (list[int]) – Indices of ordinal features.

  • metadata (dict[int, dict[str, Any]]) – Metadata for ordinal features. Computed by Gower.fit() on whole data range and passed to the distance function.

  • missing_strategy (str) – Strategy for handling missing values, default is “ignore”.

  • calculation_type (str) – Type of calculation for ordinal distance, available options are “kaufman” and “podani”. Default is “kaufman”.

  • weights (Optional[np.ndarray]) – Optional weight per ordinal feature.

Returns:

  • sum_diff: matrix (n_x, n_y) of weighted, normalized ordinal distances

  • count_present: matrix (n_x, n_y) of counts of present (non-missing) features

Return type:

tuple[np.ndarray, np.ndarray]