{"id":23974000,"url":"https://github.com/vedantvare/spam-mail-detection","last_synced_at":"2026-07-02T03:31:31.153Z","repository":{"id":270362548,"uuid":"910128919","full_name":"VedantVare/Spam-Mail-Detection","owner":"VedantVare","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-30T15:15:55.000Z","size":2200,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T16:17:58.521Z","etag":null,"topics":["dataset","ipynb","machine-learning","natural-language-processing","spam-classification","spam-detection","spam-email-classifier","spam-email-detection","spam-email-recognition","spam-filtering"],"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/VedantVare.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-12-30T15:07:47.000Z","updated_at":"2024-12-30T15:31:04.000Z","dependencies_parsed_at":"2024-12-30T15:39:16.280Z","dependency_job_id":"fc424b0a-1b50-4106-8105-b30ce167622e","html_url":"https://github.com/VedantVare/Spam-Mail-Detection","commit_stats":null,"previous_names":["vedantvare/spam-mail-detection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/VedantVare/Spam-Mail-Detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VedantVare%2FSpam-Mail-Detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VedantVare%2FSpam-Mail-Detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VedantVare%2FSpam-Mail-Detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VedantVare%2FSpam-Mail-Detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VedantVare","download_url":"https://codeload.github.com/VedantVare/Spam-Mail-Detection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VedantVare%2FSpam-Mail-Detection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270837412,"owners_count":24654378,"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-08-17T02:00:09.016Z","response_time":129,"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":["dataset","ipynb","machine-learning","natural-language-processing","spam-classification","spam-detection","spam-email-classifier","spam-email-detection","spam-email-recognition","spam-filtering"],"created_at":"2025-01-07T05:20:25.163Z","updated_at":"2026-07-02T03:31:31.113Z","avatar_url":"https://github.com/VedantVare.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spam Email Classification\n\nThis project demonstrates how to classify emails as **Spam** or **Ham (Not Spam)** using Natural Language Processing (NLP) and a Random Forest Classifier.\n\n## Features\n- **Preprocessing**: Cleans and processes email text (removes punctuation, converts to lowercase, stems words, and removes stopwords).\n- **Vectorization**: Converts text data into numerical format using CountVectorizer.\n- **Model Training**: Uses a Random Forest Classifier for prediction.\n- **Prediction**: Classifies new emails as Spam or Ham.\n\n## Requirements\n- Python 3.7 or higher\n- Libraries:\n  - `numpy`\n  - `pandas`\n  - `nltk`\n  - `scikit-learn`\n\nInstall required libraries:\n```bash\npip install numpy pandas nltk scikit-learn\n```\n\n## Dataset\nThe dataset used for this project:\n- **Columns**:\n  - `text`: The email content.\n  - `label_num`: The label (0 for Ham, 1 for Spam).\n\nReplace `'spam_ham_dataset.csv'` with your dataset file.\n\n## How It Works\n1. **Data Preprocessing**:\n   - Converts text to lowercase.\n   - Removes punctuation.\n   - Applies stemming to reduce words to their root forms.\n   - Removes stopwords (e.g., \"the\", \"is\", \"in\").\n\n2. **Feature Extraction**:\n   - Text is converted to a bag-of-words representation using `CountVectorizer`.\n\n3. **Model Training**:\n   - Splits data into training and testing sets.\n   - Trains a Random Forest Classifier on the training data.\n\n4. **Email Prediction**:\n   - Takes an example email, preprocesses it, and predicts if it's Spam or Ham.\n\n## Usage\n1. Load the dataset: \n   ```python\n   data = pd.read_csv('spam_ham_dataset.csv')\n   ```\n2. Run the code to train the model and evaluate accuracy:\n   ```python\n   cl.score(X_test, y_test)\n   ```\n3. Predict an email:\n   ```python\n   prediction = cl.predict(x_email)\n   print(f\"Prediction: {'Spam' if prediction[0] == 1 else 'Ham'}\")\n   ```\n\n## Output\n- Prints the model's prediction (Spam or Ham) for a sample email.\n- Displays the actual label from the dataset for comparison.\n\n## Notes\n- Ensure the dataset is in the correct format before running the notebook.\n- The `nltk` library requires downloading stopwords:\n  ```python\n  nltk.download('stopwords')\n  ```\n\n## License\nFeel free to use and modify this project for learning purposes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvedantvare%2Fspam-mail-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvedantvare%2Fspam-mail-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvedantvare%2Fspam-mail-detection/lists"}