INNER CODE UNIT · Python

_mean_match_nearest_neighbors

AnotherSamWilson/miceforest · miceforest/imputation_kernel.py:585

    def _mean_match_nearest_neighbors(
        mean_match_candidates: int,
        bachelor_preds: DataFrame,
        candidate_preds: DataFrame,
        candidate_values: Series,
        random_state: np.random.RandomState,
        hashed_seeds: Optional[np.ndarray] = None,
    ) -> Series:
        """
        Determines the values of candidates which will be used to impute the bachelors
        """

        assert mean_match_candidates > 0, "Do not use nearest_neighbors with 0 mmc."
        num_bachelors = bachelor_preds.shape[0]

        # balanced_tree = False fixes a recursion issue for some reason.
        # https://github.com/scipy/scipy/issues/14799
        kd_tree = KDTree(candidate_preds, leafsize=16, balanced_tree=False)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…