skhubness.reduction.LocalScaling — scikit-hubness 0.21.0 documentation

# skhubness.reduction.LocalScaling

class `skhubness.reduction.` `LocalScaling`(k: int = 5, method: str = 'standard', verbose: int = 0, **kwargs)

  Hubness reduction with Local Scaling [Rf1f7cb70176a-1].

  Parameters
    k: int, default = 5

      Number of neighbors to consider for the rescaling

    method: ‘standard’ or ‘nicdm’, default = ‘standard’

      Perform local scaling with the specified variant:

      - ‘standard’ or ‘ls’ rescale distances using the distance to the k-th neighbor

      - ‘nicdm’ rescales distances using a statistic over distances to k neighbors

    verbose: int, default = 0

      If verbose > 0, show progress bar.

  References

  Rf1f7cb70176a-1

    Schnitzer, D., Flexer, A., Schedl, M., & Widmer, G. (2012). Local and global scaling reduce hubs in space. The Journal of Machine Learning Research, 13(1), 2871–2902.

  `__init__`(self, k: 'int' = 5, method: 'str' = 'standard', verbose: 'int' = 0, **kwargs)

    Initialize self. See help(type(self)) for accurate signature.

  Methods

  `__init__`(self, k, method, verbose, \*\*kwargs) | Initialize self.
  `fit`(self, neigh_dist, neigh_ind[, X]) | Fit the model using neigh_dist and neigh_ind as training data.
  `fit_transform`(self, neigh_dist, neigh_ind, X) | Equivalent to call .fit().transform()
  `transform`(self, neigh_dist, neigh_ind[, X]) | Transform distance between test and training data with Mutual Proximity.

  `fit`(self, neigh_dist, neigh_ind, X=None, assume_sorted: 'bool' = True, *args, **kwargs) → 'LocalScaling'

    Fit the model using neigh_dist and neigh_ind as training data.

    Parameters
      neigh_dist: np.ndarray, shape (n_samples, n_neighbors)

        Distance matrix of training objects (rows) against their individual k nearest neighbors (colums).

      neigh_ind: np.ndarray, shape (n_samples, n_neighbors)

        Neighbor indices corresponding to the values in neigh_dist.

      X: ignored
      assume_sorted: bool, default = True

        Assume input matrices are sorted according to neigh_dist. If False, these are sorted here.

  `fit_transform`(self, neigh_dist, neigh_ind, X, assume_sorted=True, return_distance=True, *args, **kwargs)

    Equivalent to call .fit().transform()

  `transform`(self, neigh_dist, neigh_ind, X=None, assume_sorted: 'bool' = True, *args, **kwargs) → '(np.ndarray, np.ndarray)'

    Transform distance between test and training data with Mutual Proximity.

    Parameters
      neigh_dist: np.ndarray, shape (n_query, n_neighbors)

        Distance matrix of test objects (rows) against their individual k nearest neighbors among the training data (columns).

      neigh_ind: np.ndarray, shape (n_query, n_neighbors)

        Neighbor indices corresponding to the values in neigh_dist

      X: ignored
      assume_sorted: bool, default = True

        Assume input matrices are sorted according to neigh_dist. If False, these are partitioned here.

        NOTE: The returned matrices are never sorted.

    Returns
      hub_reduced_dist, neigh_ind

        Local scaling distances, and corresponding neighbor indices

    Notes

    The returned distances are NOT sorted! If you use this class directly, you will need to sort the returned matrices according to hub_reduced_dist. Classes from `skhubness.neighbors` do this automatically.