{"id":15783627,"url":"https://github.com/deepmancer/tweet-disaster-detection","last_synced_at":"2025-04-01T16:30:48.223Z","repository":{"id":204333819,"uuid":"708347054","full_name":"deepmancer/tweet-disaster-detection","owner":"deepmancer","description":"fine-tuned BERT and scikit-learn models for real-time classification of disaster-related tweets, using TensorFlow, Keras, and Transformers. .","archived":false,"fork":false,"pushed_at":"2024-08-16T11:29:17.000Z","size":4590,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-11T20:02:56.143Z","etag":null,"topics":["bert","bert-fine-tuning","classification","fine-tuning","huggingface-transformers","keras","keras-tensorflow","natural-language-processing","nlp","scikit-learn","tensorflow","tensorflow2","tokenizer","transformers"],"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/deepmancer.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":"2023-10-22T09:41:45.000Z","updated_at":"2024-08-26T08:52:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"286910e2-348a-451e-aacf-f8f9926e9cd8","html_url":"https://github.com/deepmancer/tweet-disaster-detection","commit_stats":null,"previous_names":["alirezaheidari-cs/tweet-disaster-detection","deepmancer/tweet-disaster-detection"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Ftweet-disaster-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Ftweet-disaster-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Ftweet-disaster-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Ftweet-disaster-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepmancer","download_url":"https://codeload.github.com/deepmancer/tweet-disaster-detection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246620295,"owners_count":20806742,"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":["bert","bert-fine-tuning","classification","fine-tuning","huggingface-transformers","keras","keras-tensorflow","natural-language-processing","nlp","scikit-learn","tensorflow","tensorflow2","tokenizer","transformers"],"created_at":"2024-10-04T20:00:22.177Z","updated_at":"2025-04-01T16:30:48.212Z","avatar_url":"https://github.com/deepmancer.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌩️ Tweet Disaster Detection\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/TensorFlow-FF6F00.svg?style=for-the-badge\u0026logo=TensorFlow\u0026logoColor=white\" alt=\"TensorFlow\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Keras-D00000.svg?style=for-the-badge\u0026logo=Keras\u0026logoColor=white\" alt=\"Keras\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Hugging%20Face-FFD21E.svg?style=for-the-badge\u0026logo=Hugging-Face\u0026logoColor=black\" alt=\"Hugging Face\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/scikitlearn-F7931E.svg?style=for-the-badge\u0026logo=scikit-learn\u0026logoColor=white\" alt=\"scikit-learn\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/python-3670A0?style=for-the-badge\u0026logo=python\u0026logoColor=ffdd54\" alt=\"Python\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Jupyter-F37626.svg?style=for-the-badge\u0026logo=Jupyter\u0026logoColor=white\" alt=\"Jupyter\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge\" alt=\"License\"\u003e\n\u003c/p\u003e\n\n---\n\n## 📘 Introduction\n\nWelcome to the **Tweet Disaster Detection** repository! This project is an advanced Natural Language Processing (NLP) solution designed to identify disaster-related tweets in real-time. By leveraging cutting-edge machine learning and deep learning techniques, this system empowers decision-makers with timely information to respond effectively to emergencies. 🌟\n\nWith the explosion of social media usage, the ability to rapidly detect disaster events through user-generated content has become critical. Our solution is optimized for accuracy and reliability, ensuring robust disaster identification.\n\n---\n\n## 🌟 Key Features\n\n- **State-of-the-Art Models**: Fine-tuned **BERT** transformer for high-precision tweet classification.\n- **Real-Time Analysis**: Designed to process and classify tweets quickly and accurately.\n- **Actionable Insights**: Focused on real-world applications, such as early disaster warnings and accurate reporting.\n- **Scalable Solution**: Easily adaptable to different datasets or NLP tasks.\n\n---\n\n## 🔧 Libraries and Frameworks\n\nThis project utilizes several powerful tools:\n\n- **[TensorFlow](https://www.tensorflow.org/)** and **[Keras](https://keras.io/)**: Core frameworks for implementing and fine-tuning the BERT model.\n- **[Huggingface Transformers](https://huggingface.co/transformers/)**: Pre-trained BERT models and tokenization utilities for NLP tasks.\n- **[scikit-learn](https://scikit-learn.org/)**: For traditional ML tasks like Naive Bayes classification and evaluation metrics.\n- **[Matplotlib](https://matplotlib.org/)**: Visualization tools for model performance analysis.\n- **[Pandas](https://pandas.pydata.org/)**: Data manipulation and preprocessing for tweet analysis.\n\n---\n\n## 💡 Project Overview\n\nIn a flood of tweets generated every second, discerning disaster-related content is challenging. This system addresses this challenge by distinguishing tweets that indicate real disasters from irrelevant content, using a fine-tuned **BERT** model for exceptional performance.\n\n### 🧠 Model Overview\n\nOur primary model is a fine-tuned **BERT** transformer with the following pipeline:\n\n1. **Preprocessing**:\n   - Tweets are tokenized with BERT's tokenizer, converting text into token IDs, attention masks, and segment IDs.\n\n2. **Model Architecture**:\n   - A dense layer is added to the pre-trained BERT model to classify tweets as disaster-related or not.\n\n   ```python\n   input_word_ids = Input(shape=(self.max_seq_length,), dtype=tf.int32, name='input_word_ids')\n   input_mask = Input(shape=(self.max_seq_length,), dtype=tf.int32, name='input_mask')\n   segment_ids = Input(shape=(self.max_seq_length,), dtype=tf.int32, name='segment_ids')\n\n   pooled_output, sequence_output = self.bert_layer([input_word_ids, input_mask, segment_ids])\n   clf_output = sequence_output[:, 0, :]\n   out = Dense(1, activation='sigmoid')(clf_output)\n   model = Model(inputs=[input_word_ids, input_mask, segment_ids], outputs=out)\n   ```\n\n3. **Training**:\n   - Trained using **SGD optimizer** with learning rate `0.0001` and momentum `0.8`.\n   - Metrics tracked: accuracy, precision, recall, and F1-score.\n\n---\n\n## 🚀 Results\n\n| Model          | Precision | Recall | Accuracy | F1-Score |\n|----------------|:---------:|:------:|:--------:|:--------:|\n| **BERT**       | 86%       | 84%    | 85%      | 86%      |\n| **Naive Bayes**| 82%       | 70%    | 56%      | 75%      |\n\n### 📊 Visualizations\n\n- **Learning Curves**: Visualize accuracy, precision, and recall across epochs.\n- **Confusion Matrix**: Detailed analysis of model predictions.\n\n---\n\n## 🌍 Real-World Applications\n\nThis system has several impactful applications:\n\n1. **Early Warning Systems**: Provide timely disaster alerts for proactive interventions.\n2. **Accurate Reporting**: Filter out irrelevant information for reliable disaster communication.\n3. **Emergency Response**: Aid first responders with real-time disaster insights.\n\n---\n\n## 🛠️ How to Use\n\n### Prerequisites\n\n- Python 3.7 or higher\n- Recommended: NVIDIA GPU for faster training (optional)\n\n### Installation Steps\n\n1. **Clone the Repository**:\n   ```bash\n   git clone https://github.com/deepmancer/tweet-disaster-detection.git\n   cd tweet-disaster-detection\n   ```\n\n2. **Install Dependencies**:\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n3. **Run the Jupyter Notebook**:\n   - Open `Advanced_Data_Science_Capstone.ipynb` to explore the code and see results.\n\n4. **Predict Disaster Tweets**:\n   - Follow the notebook instructions to classify new tweets using the trained model.\n\n---\n\n## 🤝 Contributing\n\nWe welcome contributions to enhance this project! Here's how you can contribute:\n\n1. Fork the repository.\n2. Create a feature branch:\n   ```bash\n   git checkout -b feature-name\n   ```\n3. Commit your changes:\n   ```bash\n   git commit -m \"Description of changes\"\n   ```\n4. Push your branch:\n   ```bash\n   git push origin feature-name\n   ```\n5. Open a Pull Request.\n\n---\n\n## 📄 License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## 🌟 Support \u0026 Feedback\n\nIf you find this project useful, please **star** this repository! ⭐  \nFeel free to open issues for suggestions, feedback, or questions. Let's make disaster response smarter together!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepmancer%2Ftweet-disaster-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepmancer%2Ftweet-disaster-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepmancer%2Ftweet-disaster-detection/lists"}