0
$\begingroup$

I have an unbalanced dataset, so I used SMOTEENN on the training set to resample, after training DFF,i could see the model is overfitting, could someone help me solve this? Thank You.

METRICS = [
      keras.metrics.BinaryCrossentropy(name='cross entropy'),  # same as model's loss
      keras.metrics.MeanSquaredError(name='Brier score'),
      keras.metrics.AUC(name='auc'),
      keras.metrics.F1Score(name="f1_score"), 
]
model = Sequential([
    Dense(10, activation='relu', input_shape=(x_train_resampled.shape[1],), kernel_regularizer=L2(0.01)),
    Dense(10, activation='relu', kernel_regularizer=L2(0.01)),
    Dense(1, activation='sigmoid')
])

model.compile(optimizer=Adam(learning_rate=0.001),
              loss='binary_crossentropy',
              metrics=METRICS)
# early_stopping = EarlyStopping(verbose=1, patience=10, restore_best_weights=True,mode='max')
history = model.fit(x_train_resampled, y_train_resampled, epochs=100, batch_size=2048,validation_data=(x_val,y_val))

# model.fit(x_train_resampled, y_train_resampled, epochs=100, batch_size=32, validation_split=0.2)

y_pred = model.predict(x_test)
roc_auc = roc_auc_score(y_test, y_pred)
threshold = 0.5
y_pred_binary = (y_pred > threshold).astype(int)
print("Test ROC-AUC score:", roc_auc)
print(classification_report_imbalanced(y_test, y_pred_binary))
```
$\endgroup$
1
  • 1
    $\begingroup$ In general, overfitting is not related to target imbalance. To counter overfitting, a number of techniques e.g. early-stopping are available. GIYBF. $\endgroup$
    – lpounng
    Apr 23 at 9:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.