{"id":31699406,"url":"https://github.com/rishishanthan/lstm-sentiment-analysis","last_synced_at":"2026-05-15T13:03:44.728Z","repository":{"id":318583838,"uuid":"1071905158","full_name":"rishishanthan/lstm-sentiment-analysis","owner":"rishishanthan","description":"End-to-end sentiment analysis with a stacked LSTM in PyTorch — custom tokenization, embeddings, padding, class imbalance handling, and thorough evaluation.","archived":false,"fork":false,"pushed_at":"2025-10-08T02:22:47.000Z","size":7828,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-08T03:27:05.428Z","etag":null,"topics":["deep-learning","lstm","nlp","pytorch","rnn","sentiment-analysis","sequence-modeling","text-classification","tokenization","torchtext"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/rishishanthan.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-08T01:35:23.000Z","updated_at":"2025-10-08T02:25:11.000Z","dependencies_parsed_at":"2025-10-08T03:27:07.114Z","dependency_job_id":"3870d4e7-c7b8-49ec-909a-cae0d82d6f6d","html_url":"https://github.com/rishishanthan/lstm-sentiment-analysis","commit_stats":null,"previous_names":["rishishanthan/lstm-sentiment-analysis"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/rishishanthan/lstm-sentiment-analysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishishanthan%2Flstm-sentiment-analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishishanthan%2Flstm-sentiment-analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishishanthan%2Flstm-sentiment-analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishishanthan%2Flstm-sentiment-analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rishishanthan","download_url":"https://codeload.github.com/rishishanthan/lstm-sentiment-analysis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishishanthan%2Flstm-sentiment-analysis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33067476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","nlp","pytorch","rnn","sentiment-analysis","sequence-modeling","text-classification","tokenization","torchtext"],"created_at":"2025-10-08T19:43:22.213Z","updated_at":"2026-05-15T13:03:44.724Z","avatar_url":"https://github.com/rishishanthan.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LSTM Sentiment Analysis (PyTorch)\n\nA complete, production-friendly **sentiment analysis** pipeline built around a stacked **LSTM**.  \nThis project includes robust tokenization, vocabulary building, padding/masking, class-imbalance handling, and a clean training loop with early stopping and LR scheduling.\n\n---\n\n## 🔍 Highlights\n- **Custom tokenization \u0026 vocab** (torchtext/nltk) with OOV handling\n- **Embedding layer** (random or pretrained vectors if provided)\n- **Stacked LSTM** (optionally bidirectional) + dropout regularization\n- **Packed sequences** for efficient variable-length batching\n- **Class weights / focal loss** option for imbalance\n- **Thorough evaluation**: Accuracy, Precision/Recall/F1, ROC/PR curves, confusion matrix\n\n---\n\n## 🏗️ Model\n- Embedding(d_model=EMB_DIM)\n- LSTM: 2–3 layers, hidden size = H, dropout = 0.3–0.5\n- Bidirectional (optional)\n- Classifier head: Linear → Softmax\n\n- ### Loss: CrossEntropy (or focal)\n- ### Optimizer: Adam (lr=1e-3 default)\n- ### Scheduler: ReduceLROnPlateau\n\n## 🧾 requirements\n```text\ntorch==2.4.1\ntorchtext==0.19.1\nnumpy==2.1.3\npandas==2.2.3\nmatplotlib==3.9.3\nseaborn==0.13.2\nscikit-learn==1.5.2\ntqdm==4.66.5\nnltk==3.9.1\n```\n\n## 📌 Insights\n- Bidirectional LSTM improves recall on minority classes\n- Packed sequences + masking stabilize training\n- Moderate dropout (0.3–0.5) and LR scheduling prevent overfitting\n\n## 📦 Weights\nIf you prefer to reuse my trained model, weights are attached to the repo.\n\n## 📁 Dataset\nThis is a dataset for binary sentiment classification containing substantially more data than previous benchmark datasets. We provide a set of 25,000 highly polar movie reviews for training, and 25,000 for testing. There is additional unlabeled data for use as well. Raw text and already processed bag of words formats are provided. See the README file contained in the release for more details.\n\nThe dataset can be downloaded through the Link: https://ai.stanford.edu/~amaas/data/sentiment/\n\n### Publications Using the Dataset\nAndrew L. Maas, Raymond E. Daly, Peter T. Pham, Dan Huang, Andrew Y. Ng, and Christopher Potts. (2011). Learning Word Vectors for Sentiment Analysis. The 49th Annual Meeting of the Association for Computational Linguistics (ACL 2011).\n\n## 📊 Results\nAll the results from my run including train, test, validation results are in Notebook file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frishishanthan%2Flstm-sentiment-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frishishanthan%2Flstm-sentiment-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frishishanthan%2Flstm-sentiment-analysis/lists"}