Spaces:
Runtime error
Runtime error
revert max count to max class
Browse files- train_main.py +7 -9
train_main.py
CHANGED
|
@@ -6,18 +6,17 @@ from src import data, features, model, augmentation
|
|
| 6 |
|
| 7 |
|
| 8 |
def process_dataset_with_augmentation(df, is_training=False):
|
| 9 |
-
|
| 10 |
-
Loops through the dataframe.
|
| 11 |
-
If is_training=True, it augments minority classes to balance the data.
|
| 12 |
-
|
| 13 |
X = []
|
| 14 |
y = []
|
| 15 |
|
| 16 |
# 1. Calculate Statistics for Balancing (Only needed for training)
|
| 17 |
if is_training:
|
| 18 |
class_counts = df['target'].value_counts().to_dict()
|
| 19 |
-
max_count =
|
| 20 |
-
print(f" [Augmentation] Balancing classes to match majority count: {max_count}")
|
| 21 |
|
| 22 |
total = len(df)
|
| 23 |
|
|
@@ -59,9 +58,8 @@ def process_dataset_with_augmentation(df, is_training=False):
|
|
| 59 |
|
| 60 |
|
| 61 |
def main():
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
It produces -between others- plots and a model saved in serialized format (classes.pkl) """
|
| 65 |
# 1. Load Data (Metadata only)
|
| 66 |
df, classes = data.load_metadata(limit=None) # Adjust limit as needed
|
| 67 |
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def process_dataset_with_augmentation(df, is_training=False):
|
| 9 |
+
|
| 10 |
+
#Loops through the dataframe.
|
| 11 |
+
#If is_training=True, it augments minority classes to balance the data.
|
| 12 |
+
|
| 13 |
X = []
|
| 14 |
y = []
|
| 15 |
|
| 16 |
# 1. Calculate Statistics for Balancing (Only needed for training)
|
| 17 |
if is_training:
|
| 18 |
class_counts = df['target'].value_counts().to_dict()
|
| 19 |
+
max_count = max(class_counts.values()) print(f" [Augmentation] Balancing classes to match majority count: {max_count}")
|
|
|
|
| 20 |
|
| 21 |
total = len(df)
|
| 22 |
|
|
|
|
| 58 |
|
| 59 |
|
| 60 |
def main():
|
| 61 |
+
#This is the starting point of the training.
|
| 62 |
+
#It produces -between others- plots and a model saved in serialized format (classes.pkl)
|
|
|
|
| 63 |
# 1. Load Data (Metadata only)
|
| 64 |
df, classes = data.load_metadata(limit=None) # Adjust limit as needed
|
| 65 |
|