Skip to content

Commit

Permalink
adding smote oversampling (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaBarzgar committed Mar 7, 2023
1 parent 0cd4acf commit 4c3710e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ def vectorize(self, tokens_records, encoder):
logger.debug("transforming of records into vectors is finished")
return vectors

def oversample_by_smote(self):
smote = SMOTE(random_state=42)
self.data, self.labels = smote.fit_resample(self.data.to_dense(), self.labels)

def __getitem__(self, index):
return self.data[index], self.labels[index]

Expand All @@ -155,10 +159,6 @@ def __len__(self):
def shape(self):
return self.data.shape

def oversample_by_smote(self):
smote = SMOTE(random_state=42)
self.data, self.labels = smote.fit_resample(self.data.to_dense(), self.labels)



class TimeBasedBagOfWordsDataset(BagOfWordsDataset):
Expand Down

0 comments on commit 4c3710e

Please sign in to comment.