🚀 An advanced deep learning-based sequence-to-sequence (Seq2Seq) model for event prediction with cross-validation, hyperparameter tuning, and robust evaluation.
🔗 GitHub Repository: Sequence-to-Sequence Event Prediction
The primary goal of this project is to build a reliable sequence-to-sequence (Seq2Seq) framework that can predict future event sequences from historical event data.
This work focuses on:
- Learning temporal patterns in sequential data using an encoder-decoder architecture.
- Improving generalization through cross-validation and configuration search.
- Selecting and validating the best-performing model on unseen test data.
The project follows a structured training-and-evaluation workflow:
-
Data Loading & Preprocessing
- Reads event sequence data from
Events.csv. - Prepares data for sequence modeling and K-fold splitting.
- Reads event sequence data from
-
Model Architecture
- Uses a Bidirectional LSTM Encoder-Decoder architecture.
- Includes teacher forcing during training (configured ratio).
-
K-Fold Cross-Validation
- Trains across multiple folds to reduce overfitting and increase robustness.
-
Hyperparameter Tuning
- Searches over configurable settings (hidden sizes, layers, epochs, learning rates, etc.) from
config.yaml.
- Searches over configurable settings (hidden sizes, layers, epochs, learning rates, etc.) from
-
Post-Training Analysis
- Compares trained configurations and identifies the best model using validation metrics.
-
Retraining & Final Evaluation
- Retrains the selected best configuration.
- Evaluates final performance on test data and stores results.
Based on the repository’s workflow and outputs:
- The multi-stage pipeline (train → analyze → retrain) improves model selection reliability.
- Cross-validation + hyperparameter tuning provides better confidence in model robustness versus single-run training.
- The project records both intermediate and final results in structured files:
all_jobs_results.csvfor training-stage outcomes.final_test_results.csvfor final test performance.
- The architecture is well-suited for sequence forecasting tasks where event order and temporal context matter.
Note: Numerical results depend on dataset version and chosen configuration in
config.yaml.
This repository presents a complete and reproducible Seq2Seq event prediction pipeline using LSTM-based encoder-decoder networks.
In summary, it delivers:
- A configurable deep learning training framework.
- Robust model selection through K-fold validation and post-analysis.
- Final retraining and performance reporting for unbiased test evaluation.
The project can serve as a strong baseline for future extensions such as attention mechanisms, transformer-based sequence models, or richer event feature engineering.
📂 Sequence-to-Sequence-Event-Prediction
├── main.py # Runs the full training pipeline
├── train.py # Training & validation functions
├── post_analysis.py # Selects the best model after training
├── retrain.py # Retrains the best model and evaluates on test set
├── model_definition.py # LSTM-based encoder-decoder model
├── data_loader.py # Data preprocessing & k-fold dataset preparation
├── metrics.py # Custom loss & evaluation metrics
├── utils.py # Utility functions (logging, config handling, plotting)
├── config.yaml # Configuration settings for training jobs
├── Events.csv # Dataset file (input)
└── README.md # Project documentation
git clone https://github.com/ShalinVachheta017/sequence-2-sequence-Event-Prediction.git
cd sequence-2-sequence-Event-Predictionpip install -r requirements.txtEnsure that Events.csv (dataset file) is present in the root directory.
Run the full training pipeline:
python main.pyThis script:
- Loads data from
Events.csv - Trains the model with multiple hyperparameter combinations (from
config.yaml) - Saves logs and outputs into
./logsand./outputs
Select the best-performing model after training:
python post_analysis.pyRetrain the selected best model and evaluate on test data:
python retrain.pyOutputs are saved to final_test_results.csv.
To modify hyperparameters (batch size, epochs, learning rate, etc.), edit config.yaml.
Example:
general:
batch_size: 8
epochs_list: [40, 80, 100, 120]
learning_rates: [0.001]
hidden_sizes: [64, 128, 256]
num_layers_options: [1, 2, 3]
bidirectional_options: [true, false]The model is evaluated using:
- Cross-Entropy Loss (training and validation)
- Accuracy and Coverage (post-training and final evaluation)
Stored result files:
all_jobs_results.csv(training phase)final_test_results.csv(final evaluation)
Encoder (BiLSTM) → Decoder (LSTM) → Fully Connected Layer
Teacher forcing is used during training.
Feel free to fork, open issues, and submit pull requests.
This project is open-source under the MIT License.