Skip to content

Commit

Permalink
Change class label Exception to print
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianstando committed Mar 23, 2023
1 parent fe75f3e commit a78a6f8
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions edgaro/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,18 @@ def fit(self, y: pd.Series) -> _TargetEncode:
elif self.majority_class_label is not None:
names = names.tolist()
ind = names.index(self.majority_class_label)
if counts[0] == counts[1]:
self.mapping = {
names[0 if ind == 1 else 1]: 1,
names[ind]: 0

if (ind == 1 and counts[0] > counts[1]) or (ind == 0 and counts[1] > counts[0]):
print('Majority class label may be wrong!')
print('It may be an error or a result of undersampling method ' +
'(it might have happened that there is less observations in the initial majority class ' +
'then in the initial minority class)!')

self.mapping = {
names[0 if ind == 1 else 1]: 1,
names[ind]: 0
}
return self
elif (ind == 1 and counts[0] > counts[1]) or (ind == 0 and counts[1] > counts[0]):
raise Exception('Wrong majority class label!')
return self

if counts[0] < counts[1]:
index_min = 0
Expand Down

0 comments on commit a78a6f8

Please sign in to comment.