Sentiment Analysis using SVM

Fajar

Fajar Satria

Sentiment Analysis using SVM

This project is a simple implementation of sentiment analysis using the Support Vector Machine (SVM) algorithm with scikit-learn. The dataset is sourced from a public GitHub repository, and the model utilizes TF-IDF vectorization to convert text into numerical features.

๐Ÿ“‚ File Structure

main.ipynb: The main notebook containing the entire process of training, evaluation, and prediction of the model.
vectorizer.sav: The saved vectorizer model file after training.
classifier.sav: The trained SVM classification model file.
README.md: Documentation of this project.

๐Ÿ›  Technologies and Libraries

Python 3.x
Pandas
Scikit-learn
TfidfVectorizer
Pickle
Jupyter Notebook

๐Ÿš€ Execution Steps

Clone this repository:
git clone https://github.com/fajarwiguna/svm-sentiment-analysis.git
cd svm-sentiment-analysis
Open the notebook:
jupyter notebook main.ipynb
Run each cell one by one to see the results.

๐Ÿงช Project Features

Preprocessing: Convert text to numerical features using TF-IDF.
Training: Using SVM with a linear kernel.
Evaluation: Generates classification report including accuracy, precision, and recall metrics.
Prediction: Predict sentiment labels from manual text input.

๐Ÿ“Š Model Evaluation Results

Label Precision Recall F1-score Support Positive 0.919 0.910 0.915 100 Negative 0.911 0.920 0.915 100
This model demonstrates balanced performance in classifying positive and negative reviews, with an average F1-score of around 0.915.

๐Ÿ’ก Example Prediction Output

๐Ÿ” Sample from Dataset

162: pos - "odin is a great high school basketball ..." 600: pos - "bob the happy bastard's quickie review..." 659: pos - "good films are hard to find these days..." 1099: neg - "so ask yourself what '8mm' is all about..." 337: pos - "will hunting (matt damon) is a genius..."

๐Ÿงพ Manual Text Input (User Input)

Review: SUPERB, I AM IN LOVE IN THIS PHONE Prediction: pos
Review: Do not purchase this product. My cell phone blast when I switched the charger Prediction: neg
Review: I received defective piece display is not working properly Prediction: neg
Review: It's not even 5 days since I purchased this product. I would say this a specially blended worst Phone in all formats. Prediction: neg

๐Ÿ“œ License

This project is created solely for educational and exploratory purposes. Feel free to use it with proper attribution.
Like this project

Posted Jun 7, 2025

Implemented sentiment analysis using SVM with scikit-learn.