INNER CODE UNIT · Python

_get_nonmissing_subset_index

AnotherSamWilson/miceforest · miceforest/imputation_kernel.py:543

    def _get_nonmissing_subset_index(self, variable: str, seed: int):
        """
        Get random indices for a subset of the data in which variable is not missing.
        Used to create feature / label for training.

        replace = False because it would NOT mimic bagging for random forests.
        """

        data_subset = self.data_subset[variable]
        available_candidates = self.available_candidates[variable]
        nonmissing_ind = self._get_nonmissing_index(variable=variable)
        if (data_subset == 0) or (data_subset >= available_candidates):
            subset_index = nonmissing_ind
        else:
            rs = np.random.RandomState(seed)
            subset_index = rs.choice(nonmissing_ind, size=data_subset, replace=False)
        return subset_index

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…