{"id":18237473,"url":"https://github.com/quocanh189/sentiment_analysis_eventhub","last_synced_at":"2025-10-28T07:37:54.687Z","repository":{"id":258618659,"uuid":"874226381","full_name":"QuocAnh189/Sentiment_Analysis_EventHub","owner":"QuocAnh189","description":"This project implements a Sentiment Analysis model using a neural network architecture built with Keras. The model classifies text into binary sentiment categories (positive or negative) by leveraging word embeddings and Gated Recurrent Units (GRU) layers. Additionally, the project includes a simple Flask web application to provide a real-time sent","archived":false,"fork":false,"pushed_at":"2024-12-25T14:45:05.000Z","size":4920,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T15:48:32.142Z","etag":null,"topics":["docker","flask","nlp-machine-learning","numpy","pandas","sentiment-analysis","tensorflow"],"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/QuocAnh189.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-10-17T13:13:15.000Z","updated_at":"2024-12-25T14:45:09.000Z","dependencies_parsed_at":"2025-02-14T11:47:48.991Z","dependency_job_id":"e1df3576-0758-46c9-8f60-8b0544c5eb6d","html_url":"https://github.com/QuocAnh189/Sentiment_Analysis_EventHub","commit_stats":null,"previous_names":["quocanh189/sentiment_analysis_eventhub"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/QuocAnh189/Sentiment_Analysis_EventHub","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuocAnh189%2FSentiment_Analysis_EventHub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuocAnh189%2FSentiment_Analysis_EventHub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuocAnh189%2FSentiment_Analysis_EventHub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuocAnh189%2FSentiment_Analysis_EventHub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QuocAnh189","download_url":"https://codeload.github.com/QuocAnh189/Sentiment_Analysis_EventHub/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuocAnh189%2FSentiment_Analysis_EventHub/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281403401,"owners_count":26495042,"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","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["docker","flask","nlp-machine-learning","numpy","pandas","sentiment-analysis","tensorflow"],"created_at":"2024-11-05T02:04:41.810Z","updated_at":"2025-10-28T07:37:54.650Z","avatar_url":"https://github.com/QuocAnh189.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sentiment Analysis GRU Model\n\nThis project implements a Sentiment Analysis model using a neural network architecture built with **Keras**. The model classifies text into binary sentiment categories (positive or negative) by leveraging word embeddings and **Gated Recurrent Units (GRU)** layers. Additionally, the project includes a simple **Flask** web application to provide a real-time sentiment analysis interface.\n\n## Installation\n\nClone the repository and install the necessary dependencies using `pip`.\n\n```python\ngit clone https://github.com/QuocAnh189/Sentiment_Analysis_EventHub\npip install -r requirements.txt (note python 3.8.10)\n```\n\n## Key Features\n\n### Tokenizer Initialization\n\n- A `Tokenizer` object is initialized to handle the text data, limited to the **10,000** most frequent words.\n- The tokenizer converts the text into integer sequences using `fit_on_texts(X)` to prepare the input for the model.\n\n### Model Architecture\n\nThe model leverages three GRU layers for its architecture:\n\n#### Embedding Layer\n\n- Converts word indices into dense vectors with an embedding size of **20**.\n- Handles an input dimension of **20,000** to accommodate the vocabulary.\n\n#### GRU Layers\n\n- **First GRU Layer**: Contains **16 units** and returns sequences.\n- **Second GRU Layer**: Contains **8 units** and returns sequences.\n- **Third GRU Layer**: Contains **4 units** and does not return sequences.\n\n#### Dense Layer\n\n- A fully connected **Dense layer** with **1 output neuron** using a sigmoid activation function for binary classification (positive/negative sentiment).\n\n### Model Compilation\n\n- **Loss Function**: Binary cross-entropy (`binary_crossentropy`), as it's a binary classification task.\n- **Optimizer**: Adam optimizer with a learning rate of **0.001**.\n- **Metrics**: The model is evaluated using **accuracy**.\n\n## Usage\n\nTo use the Flask web application for real-time sentiment analysis:\n\n### Running the Web Application\n\n1. Start the Flask development server:\n\n   ```bash\n   flask run or python app.py\n   ```\n\n2. Open your web browser and go to `http://127.0.0.1:5000/`. You'll see the home page where you can input text for classification.\n\n3. Enter the text and submit it to get the sentiment prediction.\n\n### Running with Docker\n\nIn project terminal run `docker-compose up --build`\nTest api in Postman with BASE_URL and GET METHOD: `http://127.0.0.1:5000/predict`\n\n### Model Prediction Flow\n\n- **Tokenization \u0026 Padding**: Input text is tokenized using the pre-trained tokenizer and padded to match the expected input length of **241 tokens**.\n- **Prediction Output**: The model outputs a probability between **0** and **1**. If the value is greater than **0.5**, the sentiment is classified as **Positive**, otherwise it's classified as **Negative**.\n\n## Example\n\nHere’s a quick example to demonstrate how the sentiment classification works:\n\n1. Input: `\"I love this event, it is interesting\"`\n\n   - Output: **Positive** (e.g., 0.85 probability)\n\n2. Input: `\"The event was terrible and very disappointing.\"`\n   - Output: **Negative** (e.g., 0.15 probability)\n\n## Author Contact\n\nContact me with any questions!\u003cbr\u003e\n\nEmail: anquoc18092003@gmail.com\nFacebook: https://www.facebook.com/tranphuocanhquoc2003\n\n\u003cp style=\"text-align:center\"\u003eThank You so much for your time !!!\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquocanh189%2Fsentiment_analysis_eventhub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquocanh189%2Fsentiment_analysis_eventhub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquocanh189%2Fsentiment_analysis_eventhub/lists"}