Views
No views yet
sentiment_analysis/
├── main.py ← Entry point (run this!)
├── app.py ← Flask Web UI
│
├── data_preprocessing.py ← Text cleaning + TF-IDF
├── model_training.py ← 5 ML models + cross-validation
├── evaluation.py ← F1, Precision, Recall, Confusion Matrix
├── inference.py ← Predict new text (CLI)
├── bert_model.py ← BERT zero-shot + fine-tuning
├── hyperparameter_tuning.py ← GridSearchCV + Optuna
│
├── requirements.txt
└── outputs/ ← Auto-created
├── best_model.pkl
├── vectorizer.pkl
├── tuned_best_model.pkl
├── bert_finetuned/
├── confusion_matrix_*.png
├── model_comparison.png
├── grid_search_results.png
└── optuna_history.pngpip install -r requirements.txt| Command | What it does |
|---|---|
python main.py | Train all 5 ML models on sample data |
python main.py --csv data.csv | Train on your own CSV |
python main.py --tune | Train + GridSearch + Optuna tuning |
python main.py --bert | Train + BERT zero-shot predictions |
python main.py --bert --finetune | Train + fine-tune BERT on your data |
python main.py --all | Run the entire pipeline |
python main.py --predict | Interactive CLI predictor |
python main.py --web | Launch Flask web dashboard |
python app.py | Launch web UI directly |
1# Step 1 — train first
2python main.py
3
4# Step 2 — launch UI
5python app.py
6# Open: http://localhost:5000python main.py --bertpython main.py --bert --finetune --csv your_data.csvpython main.py --tuneoutputs/grid_search_results.pngoutputs/optuna_history.pngoutputs/tuned_best_model.pkl| Metric | Description |
|---|---|
| Accuracy | % correct overall |
| Precision (weighted) | Weighted exactness |
| Recall (weighted) | Weighted coverage |
| F1 Weighted | Main metric |
| F1 Macro | Unweighted avg F1 |
| F1 Micro | Global F1 |
| F1 Per Class | Per sentiment class |
| CV F1 | 5-fold cross-val F1 |
| Confusion Matrix | Visual breakdown |
1text,label
2"Great product!",positive
3"Terrible service.",negative
4"It was okay.",neutralpositive, negative, neutral