📦 Import Libraries

import numpy as np
import pandas as pd
import sklearn as skl
import matplotlib.pyplot as plt
  • numpy, pandas: Data manipulation

  • sklearn: ML tools like vectorizers and train/test split

  • matplotlib: Visualization (optional)


📚 NLP Preprocessing Setup

import re
import nltk
nltk.download('stopwords')
from nltk.corpus import stopwords
from nltk.stem.porter import PorterStemmer
  • re: Regex for text cleaning

  • nltk: Tokenization, stopwords, and stemming


🚫 Custom Stopwords

negatives = ['no', 'nor', 'not', "don't", ...]
all_stopwords = [w for w in stopwords.words('english') if w not in negatives]

Retains negative words like “not”, which are important for sentiment.