kiez.hubness_reduction.LocalScaling¶
- class kiez.hubness_reduction.LocalScaling(method: str = 'standard', **kwargs)[source]¶
Hubness reduction with Local Scaling.
Uses the formula presented in [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
Methods
__init__
([method])fit
(source[, target])kneighbors
([k])transform
(neigh_dist, neigh_ind[, query])Transform distance between test and training data with Mutual Proximity.
- transform(neigh_dist, neigh_ind, query=None) Tuple[T, T] [source]¶
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
query – Ignored
- Returns:
Local scaling distances, and corresponding neighbor indices
- Return type:
hub_reduced_dist, neigh_ind
- Raises:
ValueError – If wrong self.method was supplied
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.