IntraSiteInterpolation¶
Bases: SamplerMixin, BaseEstimator
Intra-Site Interpolation (ISI) Harmonization.
This sampler performs site-wise class balancing to reduce spurious correlations between site membership and class labels.
For each site independently: - The majority class is identified. - All minority classes are oversampled to match the majority count. - Any imblearn-compatible oversampling strategy may be used.
The method supports both binary and multi-class classification and returns a globally concatenated, site-harmonized dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interpolator
|
str or SamplerMixin instance, optional (default "smote")
|
The interpolator to use. Can be a str specifying a built-in method or an instance of SamplerMixin. Supported str methods are:
|
'smote'
|
random_state
|
int or RandomState instance or None, optional (default None)
|
The seed of the pseudo random number generator or RandomState for reproducibility. |
None
|
verbose
|
bool, optional (default True)
|
If True, logs progress information. |
False
|
**kwargs
|
dict
|
Additional keyword arguments passed to |
{}
|
Source code in src/uniharmony/interpolation/_intra_site.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
fit_resample(X, y, *, sites)
¶
Fit and resample the dataset using site-wise harmonization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
numpy.ndarray of shape (n_samples, n_features)
|
Feature matrix containing the input samples. |
required |
y
|
numpy.ndarray of shape (n_samples,)
|
Target class labels associated with each sample in |
required |
sites
|
numpy.ndarray of shape (n_samples,)
|
Site or domain identifiers indicating the origin of each sample. Resampling is performed independently within each site. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
X_resampled |
numpy.ndarray of shape (n_samples_new, n_features)
|
The feature matrix after site-wise oversampling. |
y_resampled |
numpy.ndarray of shape (n_samples_new,)
|
The corresponding class labels after resampling. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Notes
For each site, the majority class count is used as the target. All minority classes within that site are oversampled to match this count using the configured interpolator.
Source code in src/uniharmony/interpolation/_intra_site.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |