PLS-DA
Partial Least Squares Discriminant Analysis with double cross-validation.
Functions
motco.stats.pls.plsda_doubleCV(X, y, cv1_splits=7, cv2_splits=8, n_repeats=30, max_components=50, random_state=1203, n_jobs=1, progress=True)
Run canonical double-nested cross-validation for PLS-DA.
For each outer fold, the inner CV averages AUROC across its V folds and selects the n_LV with the highest mean. The outer fold's selected n_LV is then evaluated on its held-out test set. Per repeat, the K outer-fold test AUROCs are aggregated by mean (and sample std), and the per-fold n_LV choices are aggregated by mode (parsimony tie-break). One final model is refit per repeat on the full input using the modal n_LV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
DataFrame
|
The predictor variables. |
required |
y
|
Union[DataFrame, Series]
|
The outcome variable. |
required |
cv1_splits
|
int
|
Number of folds in the CV1 (inner) loop. Default: 7. |
7
|
cv2_splits
|
int
|
Number of folds in the CV2 (outer) loop. Default: 8. |
8
|
n_repeats
|
int
|
Number of repeats of the K-fold outer CV. Default: 30. |
30
|
max_components
|
int
|
Maximum number of LV to test (candidates are 1..max_components-1). Default: 50. |
50
|
random_state
|
int
|
For reproducibility. Default: 1203. |
1203
|
n_jobs
|
int
|
Number of parallel workers for the inner CV loop. Use -1 for all available CPUs. Default: 1 (serial). |
1
|
progress
|
bool
|
Whether to display a tqdm progress bar over outer folds. Default: True. |
True
|
Returns:
| Type | Description |
|---|---|
dict with keys:
|
|
Source code in src/motco/stats/pls.py
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 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
motco.stats.pls.calculate_vips(model, components=None)
Estimates Variable Importance in Projection (VIP) in Partial Least Squares (PLS)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
model generated from the PLSRegression function |
required | |
components
|
Union[None, list[int]]
|
if not None, a list of integers indicating the components to compute the VIPs from. If None, all components are taken into account. Default None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
vips |
array
|
variable importance in projection for each variable |
Source code in src/motco/stats/pls.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |