{"id":18588366,"url":"https://github.com/an0n1mity/spamclassifiereval","last_synced_at":"2025-11-02T00:30:27.566Z","repository":{"id":170745823,"uuid":"646956081","full_name":"An0n1mity/SpamClassifierEval","owner":"An0n1mity","description":"A repository for evaluating the misclassification rate of spam classification models using a threshold-based approach.","archived":false,"fork":false,"pushed_at":"2023-06-12T21:36:33.000Z","size":5093,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-26T18:44:36.218Z","etag":null,"topics":["data-analysis","machine-learning","natural-language-processing","python-programming","spam-classification","text-classification"],"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/An0n1mity.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-05-29T18:23:07.000Z","updated_at":"2023-05-29T18:32:10.000Z","dependencies_parsed_at":"2024-11-07T00:45:49.706Z","dependency_job_id":"84a019e7-7031-44c3-90fa-38a85ee84247","html_url":"https://github.com/An0n1mity/SpamClassifierEval","commit_stats":null,"previous_names":["an0n1mity/spamclassifiereval"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/An0n1mity%2FSpamClassifierEval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/An0n1mity%2FSpamClassifierEval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/An0n1mity%2FSpamClassifierEval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/An0n1mity%2FSpamClassifierEval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/An0n1mity","download_url":"https://codeload.github.com/An0n1mity/SpamClassifierEval/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239349871,"owners_count":19624204,"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":["data-analysis","machine-learning","natural-language-processing","python-programming","spam-classification","text-classification"],"created_at":"2024-11-07T00:45:40.852Z","updated_at":"2025-11-02T00:30:27.498Z","avatar_url":"https://github.com/An0n1mity.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Email Spam Classification\n\nThis repository contains code for training a spam classification model using the Naive Bayes algorithm. It also includes functions for evaluating the model's performance and visualizing the spamicity of a given file.\nAn explanation of the algorithm is given on my [github page](https://an0n1mity.github.io/posts/spam_classifier/).\n\n## Prerequisites\n- Python 3.x\n- NLTK library\n- Matplotlib library\n- NumPy library\n\n## Installation\n1. Clone the repository: `git clone https://github.com/your-username/your-repository.git`\n2. Install the required dependencies: `pip install nltk matplotlib numpy`\n3. Install nltk stop words: `import nltk nltk.download('stopwords')`\n\n## Usage\n1. Import the necessary modules:\n```python\nimport os\nfrom nltk.stem import WordNetLemmatizer\nfrom nltk.corpus import stopwords\nfrom matplotlib import pyplot as plt\nimport numpy as np\nimport re\n```\n\n2. Train the spam classification model by calling the `train_model` function:\n```python\ntrain_model(training_percent=0.8, SPAM_FOLDER='HAMS', HAM_FOLDER='SPAMS')\n```\nThis function will randomly select a percentage of files from the provided spam and ham folders for training the model. It will store the training and testing file lists in separate text files.\n\n3. Classify a file's spamicity using the `get_file_spamicity` function:\n```python\nspamicity = get_file_spamicity(filename, n=8, plot=False)\n```\nThis function calculates the spamicity of a given file by comparing the words in the file to the trained word count dictionary. It returns the calculated spamicity value.\n\n![alt text](https://github.com/An0n1mity/SpamClassifierEval/blob/master/get_file_spamicity_plot.png)\n\n4. Test misclassification for a given `n` using the `test_misclassification` function:\n```python\ntest_misclassification(testing_files_spams, testing_files_hams, n=(8, 16, 32), threshold=0.6, unseen_spamicity=0.4, plot=False, verbose=False)\n```\nThis function tests the misclassification rate of the spam classification model on the provided testing files. It compares the calculated spamicity of each file to a threshold value and counts the false positives and true negatives. It accepts an optional `n` parameter to specify the number of words used for classification. \n\n![alt text](https://github.com/An0n1mity/SpamClassifierEval/blob/master/test_misclassification_plot.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fan0n1mity%2Fspamclassifiereval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fan0n1mity%2Fspamclassifiereval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fan0n1mity%2Fspamclassifiereval/lists"}