Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed imputation order handling in ImputationKernel #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nmehran
Copy link

@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
Owner

Nice catch

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