rafaelgreca / scratchml

A Python library called ScratchML was created to build the most fundamental Machine Learning models from scratch (using only Numpy), emphasizing producing user-friendly, straightforward, and easy-to-use implementations for novices and enthusiasts.
MIT License
1 stars 2 forks source link

Binary Labeling Issue in Perceptron Model #19

Open MathieuSrour opened 2 weeks ago

MathieuSrour commented 2 weeks ago

The Perceptron model currently assumes that labels are already in a binary format of 0 and 1. However, if labels are provided in a different binary format, such as -1 and 1 (common in many datasets), the model raises an error or behaves unexpectedly.

A suggested solution would be to map any binary labels to 0 and 1 before training the Perceptron model. This adjustment can be made in the perceptron.py script within the models directory, in the following part of the code:

if len(self.classes_) == 2:

Map the unique classes to 0 and 1

y = np.where(y == self.classes_[0], 0, 1)
rafaelgreca commented 1 week ago

Hey @MathieuSrour, can you provide me some examples so I can reproduce the error and see what is happening? I'm going to work on that.