skhubness.reduction.LocalScaling¶
-
class
skhubness.reduction.
LocalScaling
(k: int = 5, method: str = 'standard', verbose: int = 0, **kwargs)[source]¶ Hubness reduction with Local Scaling [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
- 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__
(k: int = 5, method: str = 'standard', verbose: int = 0, **kwargs)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
([k, method, verbose])Initialize self.
fit
(neigh_dist, neigh_ind[, X, assume_sorted])Fit the model using neigh_dist and neigh_ind as training data.
fit_transform
(neigh_dist, neigh_ind, X[, …])Equivalent to call .fit().transform()
transform
(neigh_dist, neigh_ind[, X, …])Transform distance between test and training data with Mutual Proximity.
-
fit
(neigh_dist, neigh_ind, X=None, assume_sorted: bool = True, *args, **kwargs) → skhubness.reduction.local_scaling.LocalScaling[source]¶ 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
(neigh_dist, neigh_ind, X, assume_sorted=True, return_distance=True, *args, **kwargs)[source]¶ Equivalent to call .fit().transform()
-
transform
(neigh_dist, neigh_ind, X=None, assume_sorted: bool = True, *args, **kwargs)[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
- 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.