|
8 | 8 | predicts the held-out (test-cell x test-gene) block. Unlike the ordinary |
9 | 9 | in-sample fit R2X (which increases monotonically with rank), the BiCV R2X |
10 | 10 | penalizes overfitting and typically peaks near the "true" rank of the data. |
11 | | -
|
12 | | -The held-out cells are scored through their own projections, whose scale has |
13 | | -to be corrected for the size of the held-out slice -- see |
14 | | -:func:`_holdout_scale`. Both held-out fractions default to one half, the |
15 | | -split Owen and Perry recommend for bi-cross-validation |
16 | | -(https://arxiv.org/abs/0908.2062); it is also the split at which the |
17 | | -uncorrected score happened to be unbiased, so it is the setting under which |
18 | | -older results are comparable to current ones. |
19 | 11 | """ |
20 | 12 |
|
21 | 13 | import warnings |
@@ -99,22 +91,7 @@ def _cell_loadings( |
99 | 91 | def _holdout_scale( |
100 | 92 | cond_train: np.ndarray, cond_test: np.ndarray, n_cond: int |
101 | 93 | ) -> np.ndarray: |
102 | | - """Per-held-out-cell factor correcting `A` for the held-out slice's size. |
103 | | -
|
104 | | - PARAFAC2 writes slice ``k`` as ``P_k (B diag(a_k)) C^T`` with ``P_k`` |
105 | | - orthonormal, so the reconstruction's Frobenius norm is |
106 | | - ``||(B diag(a_k)) C^T||``, independent of how many cells the slice holds: |
107 | | - all of a slice's energy sits in ``a_k``. ``a_k`` is fit against |
108 | | - ``n_train_k`` cells, and a slice's energy grows like ``sqrt(n_k)``, so |
109 | | - reusing it unchanged for ``n_test_k`` held-out cells overstates the |
110 | | - predicted block by ``sqrt(n_train_k / n_test_k)`` -- a factor of two at |
111 | | - the default split, which drove the held-out R2X negative and made the |
112 | | - curve fall as the fit improved. |
113 | | -
|
114 | | - Correcting it needs only the cell counts, which is exact when the two |
115 | | - halves of a condition have comparable per-cell energy -- true here, |
116 | | - since the split is random within each condition. |
117 | | - """ |
| 94 | + """Per-held-out-cell factor correcting `A` for the held-out slice's size.""" |
118 | 95 | scale = np.ones(cond_test.size) |
119 | 96 | train_counts = np.bincount(cond_train, minlength=n_cond) |
120 | 97 | test_counts = np.bincount(cond_test, minlength=n_cond) |
@@ -339,11 +316,7 @@ def bicv( |
339 | 316 | held_out_cell_frac : float, optional (default: 0.5) |
340 | 317 | Fraction of cells held out per condition in each BiCV trial. |
341 | 318 | held_out_gene_frac : float, optional (default: 0.5) |
342 | | - Fraction of genes held out in each BiCV trial. Both default to a |
343 | | - half-and-half split, following Owen and Perry, who report that |
344 | | - "in simulated examples we find that a method leaving out half the |
345 | | - rows and half the columns performs well" |
346 | | - (https://arxiv.org/abs/0908.2062). |
| 319 | + Fraction of genes held out in each BiCV trial. |
347 | 320 | random_state : int, optional |
348 | 321 | Random seed for reproducibility. |
349 | 322 | tolerance : float, optional (default: 1e-6) |
|
0 commit comments