mirror of
https://github.com/tcsenpai/goldigger.git
synced 2025-06-06 18:55:21 +00:00
Implement early stopping to enhance model accuracy and prevent overfitting
- Add EarlyStopping callback to LSTM and GRU model training - Monitor validation loss with patience of 10 epochs - Automatically stop training when performance plateaus - Restore best weights found during training
This commit is contained in:
parent
7bcc3556ad
commit
65ce172f3f
@ -139,7 +139,9 @@ def walk_forward_validation(X, y, model, n_splits=5):
|
||||
model.fit(X_train_2d, y_train)
|
||||
predictions = model.predict(X_test_2d)
|
||||
elif isinstance(model, Sequential):
|
||||
model.fit(X_train, y_train, epochs=100, batch_size=32, verbose=0)
|
||||
early_stopping = EarlyStopping(monitor='val_loss', patience=10, restore_best_weights=True)
|
||||
model.fit(X_train, y_train, epochs=100, batch_size=32, verbose=0,
|
||||
validation_split=0.2, callbacks=[early_stopping])
|
||||
predictions = model.predict(X_test).flatten()
|
||||
|
||||
all_predictions.extend(predictions)
|
||||
|
Loading…
x
Reference in New Issue
Block a user