{"id":22202451,"url":"https://github.com/nullhawk/time-series-prediction","last_synced_at":"2026-05-17T00:41:01.310Z","repository":{"id":264841675,"uuid":"894391113","full_name":"nullHawk/time-series-prediction","owner":"nullHawk","description":"Predicting time sequence data using LSTM","archived":false,"fork":false,"pushed_at":"2024-11-26T12:01:23.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T07:45:21.387Z","etag":null,"topics":["deep-learning","lstm","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nullHawk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-26T09:22:21.000Z","updated_at":"2024-11-26T12:01:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"2d1e406e-3e72-4c5f-a969-cc86f196e24e","html_url":"https://github.com/nullHawk/time-series-prediction","commit_stats":null,"previous_names":["nullhawk/time-series-prediction"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullHawk%2Ftime-series-prediction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullHawk%2Ftime-series-prediction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullHawk%2Ftime-series-prediction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullHawk%2Ftime-series-prediction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nullHawk","download_url":"https://codeload.github.com/nullHawk/time-series-prediction/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246156096,"owners_count":20732364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","lstm","pytorch"],"created_at":"2024-12-02T16:23:03.698Z","updated_at":"2026-05-17T00:41:01.270Z","avatar_url":"https://github.com/nullHawk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Time Series Prediction with LSTM\n\nThis project demonstrates a time-series prediction model for predicting a sine wave using PyTorch. It employs an LSTM-based architecture to learn and predict the behavior of a sine wave, showcasing the capability of recurrent neural networks for sequence modeling.\n\n## Features\n- Generates synthetic sine wave data for training and testing.\n- Trains an LSTM-based model to predict future values of the sine wave.\n- Visualizes predictions after each training step.\n- Saves predictions as `.pdf` files for review.\n\n## Requirements\n- Python 3.x\n- PyTorch\n- NumPy\n- Matplotlib\n\nInstall the required packages using:\n```bash\npip install torch numpy matplotlib\n```\n\n## Usage\n\n### 1. Generate Data\nThe sine wave data is generated with added random shifts. The `generate_sinewave.py` script provides:\n- `generate()`: Creates training and testing data.\n- `plot()`: Visualizes the sine wave.\n\n### 2. Train the Model\nRun `train.py` to train the LSTM model:\n```bash\npython train.py\n```\n\nDuring training:\n- The model learns the sine wave pattern.\n- Predictions for unseen data are plotted and saved at each training step (e.g., `predict1.pdf`, `predict2.pdf`, etc.).\n\n### 3. Model Architecture\nThe `LSTMPredictor` class in `model.py` defines a custom LSTM model:\n- **Two LSTM Cells**: For capturing complex temporal patterns.\n- **Linear Layer**: Maps LSTM outputs to the target space.\n\n### Results\nBelow is an example visualization of the model's predictions:\n\n![image](https://github.com/user-attachments/assets/d9bb39f4-1cda-4ef0-b870-0eae21f7e032)\n\n\n- **Solid Line**: Actual sine wave.\n- **Dashed Line**: Predicted future values.\n\nThe model progressively learns the pattern as training progresses.\n\n## File Structure\n```\n├── train.py               # Main script to train the model\n├── model.py               # LSTM model definition\n├── generate_sinewave.py   # Data generation and plotting\n├── predictX.pdf           # Generated prediction plots (after each training step)\n```\n\n## Example Output\nTraining logs:\n```\nStep: 0\nLoss: 0.0456\nTest loss: 0.0312\nStep: 1\nLoss: 0.0213\nTest loss: 0.0187\n...\n```\n\nPlots (`predictX.pdf`) show how the model's predictions improve over steps.\n\n---\n\nFeel free to clone this repository and experiment with time-series prediction using LSTM!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullhawk%2Ftime-series-prediction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnullhawk%2Ftime-series-prediction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullhawk%2Ftime-series-prediction/lists"}