INNER CODE UNIT · Python
_mean_match_binary_fast
AnotherSamWilson/miceforest · miceforest/imputation_kernel.py:626
def _mean_match_binary_fast(
mean_match_candidates: int,
bachelor_preds: DataFrame,
random_state: np.random.RandomState,
hashed_seeds: Optional[np.ndarray],
) -> np.ndarray:
"""
Chooses 0/1 randomly weighted by probability obtained from prediction.
If mean_match_candidates is 0, choose class with highest probability.
Returns a np.ndarray, because these get set to categorical later on.
"""
if mean_match_candidates == 0:
imp_values = np.floor(bachelor_preds + 0.5)
else:
num_bachelors = bachelor_preds.shape[0]
if hashed_seeds is None: