{"id":25243171,"url":"https://github.com/macabdul9/reddit-flait-detector","last_synced_at":"2025-04-05T20:42:22.796Z","repository":{"id":37224996,"uuid":"253439471","full_name":"macabdul9/reddit-flait-detector","owner":"macabdul9","description":"Reddit Flair Detector","archived":false,"fork":false,"pushed_at":"2022-12-08T04:04:40.000Z","size":87173,"stargazers_count":1,"open_issues_count":29,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T00:45:40.436Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/macabdul9.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-06T08:32:08.000Z","updated_at":"2020-09-20T18:00:01.000Z","dependencies_parsed_at":"2023-01-24T16:01:04.195Z","dependency_job_id":null,"html_url":"https://github.com/macabdul9/reddit-flait-detector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macabdul9%2Freddit-flait-detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macabdul9%2Freddit-flait-detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macabdul9%2Freddit-flait-detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macabdul9%2Freddit-flait-detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/macabdul9","download_url":"https://codeload.github.com/macabdul9/reddit-flait-detector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399898,"owners_count":20932876,"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":[],"created_at":"2025-02-12T00:45:53.569Z","updated_at":"2025-04-05T20:42:22.769Z","avatar_url":"https://github.com/macabdul9.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Client App: https://midas-rfd.web.app/\n### API: https://midas-rfd-api.herokuapp.com/\nAPI Endpoints\n  - /\n       \n   - /automated_testing/\n\n### Note: GitHub might not be able to render these notebooks due to their size, see them on nbviewer:\n- exploratory-data-analysis.ipynb: https://nbviewer.jupyter.org/github/macabdul9/midas-internship-task/blob/master/src/exploratory-data-analysis.ipynb\n  \n-   preprocessing-and-classification.ipynb: https://nbviewer.jupyter.org/github/macabdul9/midas-internship-task/blob/master/src/preprocessing-and-classification.ipynb\n- \n\n## 0. Directory Structure\n- **client/**  react app code base to call the flask api where our model is deployed\n- **server/** flask rest API code base to inference from the trained model(s) \n- **src/** \n- **requirements.txt** dependency list required to reproduce the results in local/virtual environment\n- **readme.md** That's what I am reading.\n\n\n## 1. Results\nA comprehensive report of trained models can be is given in the below table:\n| Model      | Accuracy(Test) | Dataset(train/test)     |\n| :---        |    :----:   |          ---: |\n| MultinomialNB | 59       | 48535/5393   |\n| SV Classifier | 58        | 48535/5393      |\n| RandomForest | 55       | 48535/5393   |\n| GradientBoosting | 58    | 48535/5393      |\n| Flair | 37    | 24110/3000      |\n| BiLSTM (trainable embedding layer)| 62       | 90181/10021  |\n| BiLSTM(pretrained embeddings)   | 60        | 90181/10021      |\n| CNN(pretrained embeddings)      | 63       | 90181/10021   |\n| Attention-based LSTM   | 61        | 90181/10021      |\n| DistilBERT      | 65       | 90334/10038   |\n| XLNet   | 65        | 90334/10038      |\n\n##### Download the trained models from here:\n- **DistilBERT**  https://drive.google.com/file/d/148iGfmDPL82MWhPQM15aPoJXlCUrX9N-/view?usp=sharing\n- **XLNet** https://drive.google.com/drive/folders/173S1sfBXA-qZRJ1kVP4flW45n1Hk0Zas?usp=sharing\n- **Custom Models**: https://drive.google.com/file/d/1Z9s4agLJ90MVAXB0zErVwW_J-QiSpoGZ/view?usp=sharing\n\n## 2. Data Acquisition, Cleaning and Preprocessing:\ni.  I have used pushshift API and PRAW(=Reddit API wrapper) to scrap the data from India subreddit\n\nii. PRAW was used to collect the comments of a post/submission\n\niii. Total 218371 posts were collected from Jan-2019 upto 10 April, 2020.\n\niii. Following properties of a post was collected\n  - features = [\n    'allow_live_comments', 'author', 'author_premium', 'can_mod_post', 'contest_mode', 'created_utc',\n    'full_link', 'id', 'is_crosspostable', 'is_meta', 'is_original_content', 'is_self', 'is_video',\n    'link_flair_text', 'locked', 'media_only', 'no_follow', 'num_comments', 'num_crossposts', 'over_18',\n    'parent_whitelist_status', 'permalink', 'pinned', 'score', 'selftext', 'send_replies', 'spoiler',\n    'stickied', 'title', 'total_awards_received', 'url'\n]\n  - custom_features = [\n    'comments', 'mean_comment_score'\n]\n\niv. Collected data (raw) can be downloaded from here: \n- https://drive.google.com/file/d/1uCOeV-mBSC516Pv0PNZ2g6h27mJB2uLj/view?usp=sharing\n  \niv. Undersampling, Imputation, Noise Removal, Spelling Correction, Stopword Removal, Tokenization, TF-IDF Vectorization techniques were used to clean and process the data.\n\niv. Cleaned and Preprocessed dataset can be download from here:\n- https://drive.google.com/file/d/1p4x_-JMB5Wr7LbXmUqRVT_p3hL91rVsB/view?usp=sharing\n\n\n## 3. To reproduce the results in local/virtual environments\n\ni. Clone this repo using: \n - **git clone https://github.com/macabdul9/midas-internship-task**\n\nii. Create a virtual environment(recommended but not necessary)\n- Create: **virtualenv venv**\n- Activate: \n    - **venv/Scripts/activate** *(windows)*\n    -  **source venv/bin/activate** *(linux)*\n  \niii. Install the dependencies:\n- pip install -r requirements.txt(assuming you're on the root directory of this repo)\niv. Download the raw/cleaned/preprocessed dataset from [see section 2.4 and 2.6]\n\nv. Now all the src code base can be executed\n\n## 4. To run the client app on localhost \ni. You should have node.js and npm (package manager) installed in your machine\nii. Change directory \n- cd client/\n  \niii. Install dependencies\n- npm i\n  \niv. Run app locally\n- npm start \n-  client app will be running on localhost:3000 (default port)\n\n## 5. To run the API on localhost\ni. Change directory \n- cd server/\nii. Create and activate a virtual environment (see 2.2)\niii. Install dependencies (see 2.3)\niv. Download the checkpoint from (see results) and set the path accordingly\niv. Run the flask app\n- python app.py\n- API will be running on localhost:5000(default port)\n- Use postman(or other API client tools) to make requests\n\n## 6. Screenshots of running app(and API):\n- Post Response (URL)\n![SubmissionURL](assets/client.jpg)\n\n- Post Response (txt file)\n![AutomatedTesting](assets/automated_testing.jpg)\n\n## 7. Python scripts to send POST requests to api\n\n#### i. Sending an url to / endpoint\n\n## Source: Postman\nimport requests\n\nurl = \"http://localhost:5000/?url=https://www.reddit.com/r/india/comments/g8dx13/venomous_whisper_of_rumor_mongers_manifest/\"\n\npayload = {}\n\nfiles = {}\n\nheaders = {\n  'url': 'csds'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data = payload, files = files)\n\nprint(response.text.encode('utf8'))\n\n\n\n#### ii. Sending a text file to /automated_tesing/ endpoint\n\n\nimport requests\n\nurl = \"http://localhost:5000/automated_testing/\"\n\npayload = {}\n\nfiles = [\n  ('file', open('/C:/Users/abdul/OneDrive/Desktop/sample.txt','rb'))\n]\n\nheaders = {\n  'url': 'csds'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data = payload, files = files)\n\nprint(response.text.encode('utf8'))\n\n\n\n\n## 8. Reference\n[0] Pushshift API : https://github.com/pushshift/api\n\n[1] PRAW: https://praw.readthedocs.io/en/latest/\n\n[2] SimpleTransformers: https://github.com/ThilinaRajapakse/simpletransformers\n\n[3] HugginFace transformers: https://github.com/huggingface/transformers\n\n[4] Flair: https://towardsdatascience.com/text-classification-with-state-of-the-art-nlp-library-flair-b541d7add21f\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacabdul9%2Freddit-flait-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmacabdul9%2Freddit-flait-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacabdul9%2Freddit-flait-detector/lists"}