Skip to content

Fixed imputation order handling in ImputationKernel#91

Merged
AnotherSamWilson merged 1 commit intoAnotherSamWilson:masterfrom
nmehran:fix/imputation-order-handling
Oct 19, 2025
Merged

Fixed imputation order handling in ImputationKernel#91
AnotherSamWilson merged 1 commit intoAnotherSamWilson:masterfrom
nmehran:fix/imputation-order-handling

Conversation

@nmehran
Copy link
Copy Markdown
Contributor

@nmehran nmehran commented Sep 18, 2024

This pull request addresses a bug in the ImputationKernel class related to the imputation_order parameter. The issues fixed include:

  • Typo Correction: "decending" was corrected to "descending".
  • Sorting Configuration: Updated sorting configuration for ascending order to use ascending=True.

Steps to Reproduce

The following code can be used to test and verify the changes:

import pandas as pd
import numpy as np
import miceforest as mf
from sklearn.datasets import load_iris

# Load the Iris dataset
iris_data = load_iris()
iris_df = pd.DataFrame(iris_data.data, columns=iris_data.feature_names)

# Introduce missing values
np.random.seed(42)
missing_indices = np.random.choice(iris_df.index, size=10, replace=False)
iris_df.loc[missing_indices, 'sepal length (cm)'] = np.nan
iris_df.loc[np.random.choice(iris_df.index, size=8, replace=False), 'sepal width (cm)'] = np.nan
iris_df.loc[np.random.choice(iris_df.index, size=4, replace=False), 'petal length (cm)'] = np.nan
iris_df.loc[np.random.choice(iris_df.index, size=2, replace=False), 'petal width (cm)'] = np.nan

# Initialize ImputationKernel with 'ascending' order
kernel_ascending = mf.ImputationKernel(iris_df, imputation_order='ascending')

# Initialize ImputationKernel with 'descending' order
kernel_descending = mf.ImputationKernel(iris_df, imputation_order='descending')

# Compare imputation orders
ascending_order = kernel_ascending.imputation_order
descending_order = kernel_descending.imputation_order

# Print equality comparison result
print("Are the imputation orders equal?")
print(ascending_order == descending_order)

Related Issue

This PR resolves issue #90.

- Fixed typo "decending" to "descending".
- Updated sorting configuration for ascending order to use ascending=True.

Related to issue AnotherSamWilson#90
@AnotherSamWilson
Copy link
Copy Markdown
Owner

Nice catch

@AnotherSamWilson AnotherSamWilson merged commit 2fd7772 into AnotherSamWilson:master Oct 19, 2025
@AnotherSamWilson
Copy link
Copy Markdown
Owner

This commit was merged as a part of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants