Skip to content
SHYAMFRANCISPublic

About

Movie Genre Classification Using Machine Learning A text-based classification system that predicts the genre of a movie based on its plot summary using traditional NLP techniques and machine learning models. Built using Python, Scikit-learn, and NLTK.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

-CODSOFT-

Python scikit-learn NLTK License

A CodSoft-style machine-learning practice collection: three standalone scripts covering text classification (movie genres, SMS spam) and tabular fraud detection (credit-card transactions). Each script trains multiple scikit-learn classifiers, prints accuracy / classification reports / confusion matrices, and plots evaluation charts. There is no shared src/ package or data_preprocessing.py — each .py file is self-contained (the previous README's Movie header + Credit-Card body + src/ reference described a different layout and has been replaced by this file).

Scripts and what they do

File Task Input Models Output
MOVIE GENRE CLASSIFICATIO.py Predict movie genre from plot summary Built-in 20-plot sample (plot, genre: Fantasy, Sci-Fi, Thriller, Romance, Action, Crime, Horror, Drama, Comedy) MultinomialNB, Logistic Regression, Linear SVM (probability=True), Random Forest — over TF-IDF (max_features=5000, unigrams+bigrams, English stop words) Accuracy, classification report, confusion matrix per model; cross-val / grid-search helpers in class
SPAM SMS DETECTION.py Ham vs. spam SMS classification Optional CSV path (SMSSpamDetector(data_path=...), Kaggle v1/v2 layout) or built-in 30-message sample (15 spam / 15 ham) MultinomialNB, Logistic Regression, SVM, Random Forest — over TF-IDF / Count vectors Accuracy, ROC-AUC, classification report, confusion matrix, ROC curves; cross-val + grid-search helpers
Credit Card Transactions Fraud Detection.py Fraud detection on PCA-anonymized transactions creditcard.csv (Kaggle credit-card-fraud: Time, V1–V28, Amount, Class) — script defaults to D:\creditcard.csv, edit to your path Logistic Regression (max_iter=1000), Decision Tree, Random Forest (n_estimators=100) — over StandardScaler features, stratified 80/20 split Accuracy, ROC-AUC, classification report, confusion matrix per model + combined ROC plot

Preprocessing (as implemented)

  • Movie genre: lowercase → strip non-letters → NLTK word_tokenize → stop-word removal + WordNetLemmatizer (tokens longer than 2 chars) → TF-IDF. LabelEncoder for genre labels.
  • SMS spam: lowercase → strip non-letters → whitespace normalize → Porter stemming + stop-word removal → TF-IDF / Count vectors. Label map ham/spam.
  • Credit-card fraud: drop Class as target → StandardScaler over all features → train_test_split(test_size=0.2, stratify=y, random_state=42).

Stack

Python 3.x · pandas, numpy · scikit-learn (TF-IDF, Naive Bayes, Logistic Regression, SVM, Decision Tree, Random Forest, metrics, model selection) · NLTK (punkt, stopwords, wordnet) · matplotlib, seaborn, wordcloud (movie script) · Kaggle CSVs for real-data runs.

Repository structure

-CODSOFT-/
├── MOVIE GENRE  CLASSIFICATIO.py              # MovieGenrePredictor class + sample plots
├── SPAM SMS DETECTION.py                      # SMSSpamDetector class + sample messages
├── Credit Card Transactions Fraud Detection.py # Tabular fraud pipeline (procedural)
├── .gitignore
└── LICENSE                                    # MIT (© 2025 SHYAMFRANCIS)

No requirements.txt, no src/ directory, no test suite — all dependencies are imported directly in each script.

Installation

Prerequisites: Python 3.8+, pip.

git clone https://github.com/SHYAMFRANCIS/-CODSOFT-.git
cd -CODSOFT-
pip install pandas numpy scikit-learn nltk matplotlib seaborn wordcloud
python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords'); nltk.download('wordnet')"

For the fraud script, download creditcard.csv and update the path in the script:

df = pd.read_csv(r'D:\creditcard.csv')  # ← change to your local path

Usage

Each file runs independently — pick the task you want:

# 1. Movie genre classification (uses built-in 20-plot sample, no download needed)
python "MOVIE GENRE  CLASSIFICATIO.py"

# 2. SMS spam detection (built-in 30-message sample; or pass your CSV via data_path in code)
python "SPAM SMS DETECTION.py"

# 3. Credit-card fraud detection (requires creditcard.csv — edit path first)
python "Credit Card Transactions Fraud Detection.py"

To run the spam detector on the full Kaggle SMS collection instead of the sample, instantiate with a path:

from importlib import import_module  # filenames contain spaces; or rename files
# Easiest: rename "SPAM SMS DETECTION.py" → sms_spam_detection.py, then:
# from sms_spam_detection import SMSSpamDetector
# detector = SMSSpamDetector(data_path="spam.csv")

Examples

# Movie genre script prints per-model results, e.g.:
Training Naive Bayes...
Accuracy: ...
Classification Report:
...
# Fraud script prints dataset overview + per-model results, e.g.:
Dataset shape: (284807, 31)
Logistic Regression Results:
Accuracy: ...
ROC AUC: ...
# ...then shows a combined ROC-curve plot.

Configuration

Script Key settings
Movie genre TfidfVectorizer(max_features=5000, stop_words='english', ngram_range=(1,2)); RF n_estimators=100; SVM probability=True; random_state=42
SMS spam TF-IDF / Count vectorizer choice in class; same 4-model set; cross-val + GridSearchCV helpers available
Fraud StandardScaler on all features; test_size=0.2, stratify=y; LR max_iter=1000; RF n_estimators=100

Known limitations

  • Filenames contain spaces (quote them in the shell or rename to snake_case.py for imports).
  • Fraud script's default data path is a Windows absolute path (D:\creditcard.csv) — must be edited per machine.
  • Sample datasets (20 plots, 30 messages) are for demonstration; expect modest/overfit metrics — use real Kaggle CSVs for meaningful evaluation.
  • NLTK data (punkt, stopwords, wordnet) downloads at first run if missing.
  • Plots call plt.show() and need a display (or switch to plt.savefig(...) headless).

Contributing

  1. Fork and branch per task (movie-genre, spam-sms, fraud).
  2. Prefer renaming files to space-free names and adding a requirements.txt.
  3. Open a pull request with the script output (accuracy / ROC-AUC) before and after your change.

License

MIT — see LICENSE. © 2025 SHYAMFRANCIS.

About

Movie Genre Classification Using Machine Learning A text-based classification system that predicts the genre of a movie based on its plot summary using traditional NLP techniques and machine learning models. Built using Python, Scikit-learn, and NLTK.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages