Documentation

This documentation explains how the original full application was translated into a portfolio-compatible Flask architecture and a fast browser sandbox.

Architecture Overview

  1. Data upload: users upload labelled or unlabelled CSV/Excel text data.
  2. Training: TF-IDF converts text into numerical features; Logistic Regression learns sentiment classes.
  3. Prediction: new rows are scored locally and returned with class probabilities.
  4. Analysis: local analytics calculate distribution, confidence, low-confidence records, and category breakdowns.
  5. Export: labelled outputs are downloaded as CSV for dashboards and reporting pipelines.

Technology Stack

FlaskPandasScikit-learnTF-IDFLogistic RegressionJavaScript SandboxCSV Export

Implementation Notes

The source version was converted into a standard Flask pattern with reusable ML functions, file upload routes, API endpoints, and templates. This avoids the framework-specific runtime experience and makes the project easier to deploy as a lightweight web service on Render, Railway, Fly.io, or a private server.

flask_app/
โ”œโ”€โ”€ app.py                  # Flask routes and API endpoints
โ”œโ”€โ”€ requirements.txt        # Flask + ML dependencies
โ”œโ”€โ”€ models/                 # Model/vectorizer metadata copied from source project
โ”œโ”€โ”€ sample_training_data.csv
โ”œโ”€โ”€ sample_unlabelled_data.csv
โ”œโ”€โ”€ templates/index.html
โ””โ”€โ”€ static/app.js

Run the Flask App Locally

cd pages/ai-lab/sentiment-automation/flask_app
python -m venv .venv
.venv\Scripts\activate   # Windows
pip install -r requirements.txt
python app.py

Then open http://127.0.0.1:5000. The portfolio sandbox remains available without starting Flask, while the Flask folder provides the backend-ready version of the converted application.

Security note: routine sentiment prediction uses the local model. No external AI API is required for bulk scoring. If a production chatbot or LLM explanation layer is later added, it should use explicit consent, redaction, and controlled prompts.