Hi, thank you for the great work and for making the code available!
I have a question about the binning preprocessing step in your code.
I noticed that in the binning step, the code does not directly use np.digitize, but instead calls a custom _digitize function, which introduces randomization when the bin edges contain repeated values:
rands = np.random.rand(len(x)) # uniform random numbers
digits = rands * (right_difits - left_digits) + left_digits
This means that if a value falls into a range of bins that all have the same edge value (due to duplicated quantiles), it will be assigned to a bin index uniformly at random between left_digits and right_difits.
Questions
- What is the motivation for re-implementing
_digitize with randomization, instead of using the standard deterministic np.digitize?
- Have you tried an ablation study where this randomization is disabled (e.g., always choose the smallest possible bin index)?
I am concerned that for very sparse data (such as single-cell gene expression), this randomness could introduce large variance in the preprocessed features.
- Even if this randomization helps during training, how is inference handled?
- If the same preprocessing is applied during inference, the random assignment could make predictions unstable.
- If randomization is disabled at inference, then the input distribution would differ from training.
Example
For instance, with very sparse and low-cardinality rows:
Raw: [2, 2, 1, 1, 1, 1]
Norm: [2500, 2500, 1250, 1250, 1250, 1250]
Log1p: [7.82, 7.82, 7.13, 7.13, 7.13, 7.13]
Binning: [43, 45, 26, 26, 29, 5] # 43 and 45 come from the same original value (7.82)
Running preprocessing again could produce different bin assignments for the same value, e.g.:
[50, 50, 1, 1, 1, 1] # in extreme cases
In sparse settings, even a single random misassignment can disproportionately affect the resulting feature vector and significantly impact downstream results.
Summary
- Could you clarify the intended benefit of introducing randomness in
_digitize?
- Could you share whether deterministic binning was tested?
- How should this be handled for inference to ensure consistent results?
Thanks again for your time and for considering my question!
Hi, thank you for the great work and for making the code available!
I have a question about the binning preprocessing step in your code.
I noticed that in the binning step, the code does not directly use
np.digitize, but instead calls a custom_digitizefunction, which introduces randomization when the bin edges contain repeated values:This means that if a value falls into a range of bins that all have the same edge value (due to duplicated quantiles), it will be assigned to a bin index uniformly at random between
left_digitsandright_difits.Questions
_digitizewith randomization, instead of using the standard deterministicnp.digitize?I am concerned that for very sparse data (such as single-cell gene expression), this randomness could introduce large variance in the preprocessed features.
Example
For instance, with very sparse and low-cardinality rows:
Running preprocessing again could produce different bin assignments for the same value, e.g.:
In sparse settings, even a single random misassignment can disproportionately affect the resulting feature vector and significantly impact downstream results.
Summary
_digitize?Thanks again for your time and for considering my question!