ddbourgin / numpy-ml

Machine learning, in numpy
https://numpy-ml.readthedocs.io/
GNU General Public License v3.0
15.26k stars 3.7k forks source link

Fix AttributeError in `test_naive_bayes.py` #91

Open yjin07 opened 10 months ago

yjin07 commented 10 months ago

Fixed an AttributeError in test_naivebayes.py caused by trying to access the non-existent sigma attribute of the GaussianNB object from sklearn.

In more recent versions of sklearn, the var attribute should be used to obtain the variances for each class, instead of sigma. This change replaces all references of sklearnNB.sigma with sklearnNB.var to ensure the code is compatible with the current sklearn API.

This modification ensures the correct execution of the tests and aligns with the latest version of sklearn.