Skip to content

Update kfda.py #3

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

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

Conversation

shahedahmed2023
Copy link

Title: Update KFDA implementation to address deprecated features and numerical stability issues

Description:
This PR updates the Kernel Fisher Discriminant Analysis (KFDA) implementation to address several issues:

  1. Fixes deprecated features:

    • Updates OneHotEncoder usage to specify sparse_output parameter
    • Replaces scipy.sparse.eye with numpy.eye for better compatibility
  2. Improves numerical stability:

    • Adds proper handling of edge cases in n_components calculation
    • Prevents division by zero in class mean calculations
    • Adds regularization to matrices for better conditioning
    • Implements custom prediction to avoid NearestCentroid warnings
  3. Enhances robustness:

    • Handles broadcasting issues in mean centering
    • Adds appropriate jitter to centroids when needed
    • Updates attribute checks for better compatibility with scikit-learn

These changes maintain the same mathematical approach while making the implementation more robust across a wider range of datasets and making it compatible with newer versions of scikit-learn and scipy.

Tests have been run on various datasets to ensure the accuracy is maintained while eliminating warnings.

fix deprecated lib
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.

1 participant