3D support for mice_forest_impute#1055
Merged
Merged
Conversation
mice_forest_impute
eroell
reviewed
Apr 28, 2026
eroell
left a comment
Collaborator
There was a problem hiding this comment.
Thank you!
And as for the other PR with missforest #1052 : could you create an analog snippet as PR comment with the physionet challenge data, comparing the imputed data with e.g. simpleimpute in terms of imputation quality?
eroell
reviewed
May 8, 2026
eroell
reviewed
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #949
Extends
mice_forest_imputeto handle 3D inputs, following the same flatten/unflatten pattern established forknn_impute(n_obs * n_t, n_vars)before building the DataFrame and reshapes back to(n_obs, n_vars, n_t)after imputationTechnical notes
The 3D path is asymmetric with the 2D:
column_indices = var_indicesto select columns to impute, writes back the full DataFramevar_indicesbefore flattening, usescolumn_indices = list(range(len(var_indices))), writes back only tovar_indicespositionsThis is necessary for two reasons I observed when trying to making it symmetric:
.astype()crashes on categorical columns (object dtype arrays with string values were not able to be cast to float)ValueError: 'x' must be finiteComparison of
mice_forest_imputeandsimple_imputewith mean strategy using physionet2012 dataset with a missingness of 10%:Output:
Note: I used a subset of observations (200) for this evaluation since mice_forest_impute got computationally too expensive (11988 observations × 37 variables × 48 timepoints which after flattening to (n_obs * n_t, n_vars))