# kajamalan15/airline-sentiment-analysis-nlp architecture

> Architecture diagram of the GitHub repository kajamalan15/airline-sentiment-analysis-nlp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kajamalan15/airline-sentiment-analysis-nlp
- Repository: https://github.com/kajamalan15/airline-sentiment-analysis-nlp

## Overview

#### Purpose and Entry Points
This repository is a Python NLP project for classifying airline-related tweets into positive, neutral, or negative sentiment. The interactive exploration/training workflow is centered on `Tweets.ipynb`; the application-facing entry point is likely `app.py`.

#### Source Data and Training Corpus
The primary labeled dataset is `Tweets (1).csv`. It supplies tweet text and sentiment labels for preprocessing, exploratory analysis, TF-IDF feature generation, model training, and evaluation. The project is batch-oriented around this local CSV rather than a connected streaming or API ingestion system.

#### NLP Preprocessing and Feature Engineering
Tweet text is cleaned before modeling, including removal of mentions, hashtags, URLs, and stopwords as described by the project documentation. The transformed text is converted into sparse TF-IDF vectors. The fitted vectorizer is persisted as `tfidf_vectorizer.pkl`, creating a compatibility boundary: inference text must undergo the same preparation and vectorization assumptions used during training.

#### Model Training and Selection
The notebook workflow in `Tweets.ipynb` develops sentiment classifiers using Naïve Bayes and Random Forest approaches, compares their results, and selects a best-performing model. The selected trained estimator is serialized in `best_sentiment_model.pkl`; this file is the central model artifact consumed by inference.

#### Inference Application Boundary
`app.py` is the deployment-oriented integration point. It is expected to load `best_sentiment_model.pkl` and `tfidf_vectorizer.pkl`, accept tweet input, convert it to the model feature space, and return a sentiment class. This separates interactive training work from reusable prediction-time artifacts.

#### Analysis and Visualization
`Tweets.ipynb` also serves as the exploratory and reporting surface for the dataset and classification outcomes. Matplotlib and Seaborn are the intended visualization stack, supporting sentiment distribution and model-result analysis rather than being part of the core runtime prediction path.

#### Runtime and Supporting Assets
The project runs on Python with dependencies declared in `requirements.txt`, including the data-science, NLP, and visualization ecosystem described in the README. spaCy is a material NLP dependency, while scikit-learn supplies TF-IDF and classifier implementations. `.devcontainer/devcontainer.json` provides a reproducible development-environment definition. `ImageFolder/Images` and `Project.mp4` appear to be presentation/demo assets, not production model inputs.

Main entry points: [`app.py`](https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/app.py) (Inference application), [`Tweets.ipynb`](https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/Tweets.ipynb) (Training notebook), [`requirements.txt`](https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/requirements.txt) (Python dependencies), [`tfidf_vectorizer.pkl`](https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/tfidf_vectorizer.pkl) (Fitted vectorizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training &amp; Analysis"]
  node_dataset[("Labeled tweets<br/>CSV dataset<br/>[Tweets &#40;1&#41;.csv]")]
  node_notebook["Training notebook<br/>Jupyter notebook<br/>[Tweets.ipynb]"]
  node_preprocessing["Text preprocessing<br/>NLP pipeline"]
  node_tfidf["TF-IDF features<br/>feature engineering"]
  node_model_selection["Model selection<br/>training stage"]
  node_vectorizer_artifact["Fitted vectorizer<br/>serialized artifact"]
  node_model_artifact["Selected sentiment model<br/>serialized artifact"]
  node_visualization["Analysis visualizations<br/>reporting"]
end

subgraph group_inference["Prediction Runtime"]
  node_app["Inference application<br/>Python entry point<br/>[app.py]"]
  node_input_tweet["Tweet input<br/>runtime input"]
  node_prediction_prep["Inference preparation<br/>NLP pipeline"]
  node_prediction["Sentiment prediction<br/>classification output"]
end

node_dependencies["Python dependencies<br/>dependency manifest<br/>[requirements.txt]"]
node_devcontainer["Development environment<br/>dev container config<br/>[devcontainer.json]"]
node_demo_assets["Presentation assets<br/>demo media"]

node_dataset -->|"explored and labeled for training"| node_notebook
node_notebook -->|"cleans tweets"| node_preprocessing
node_preprocessing -->|"feeds cleaned text"| node_tfidf
node_tfidf -->|"training features"| node_model_selection
node_model_selection -->|"serializes best model"| node_model_artifact
node_tfidf -->|"persists fitted vectorizer"| node_vectorizer_artifact
node_notebook -->|"produces analysis"| node_visualization
node_input_tweet -->|"submitted to"| node_app
node_app -->|"prepares input"| node_prediction_prep
node_vectorizer_artifact -->|"loads feature contract"| node_app
node_model_artifact -->|"loads estimator"| node_app
node_prediction_prep -->|"classifies with loaded artifacts"| node_prediction
node_dependencies -.->|"supports training stack"| node_notebook
node_dependencies -.->|"supports runtime stack"| node_app
node_devcontainer -.->|"provisions environment"| node_dependencies

click node_dataset "https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/Tweets%20(1).csv"
click node_notebook "https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/Tweets.ipynb"
click node_vectorizer_artifact "https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/tfidf_vectorizer.pkl"
click node_model_artifact "https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/best_sentiment_model.pkl"
click node_app "https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/app.py"
click node_dependencies "https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/requirements.txt"
click node_devcontainer "https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/.devcontainer/devcontainer.json"
click node_demo_assets "https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/ImageFolder/Images"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dataset,node_notebook,node_preprocessing,node_tfidf,node_model_selection,node_vectorizer_artifact,node_model_artifact,node_visualization toneBlue
class node_app,node_input_tweet,node_prediction_prep,node_prediction toneAmber
class node_dependencies,node_devcontainer,node_demo_assets toneNeutral
```

## Components

### Training & Analysis

Interactive batch workflow.

- [Labeled tweets](https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/Tweets%20(1).csv): CSV dataset · Tweet text and sentiment labels. · `Tweets (1).csv`
- [Training notebook](https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/Tweets.ipynb): Jupyter notebook · Explores data, trains, compares, and reports models. · `Tweets.ipynb`
- **Text preprocessing**: NLP pipeline · Removes tweet noise and stopwords.
- **TF-IDF features**: feature engineering · Converts cleaned tweets to sparse vectors.
- **Model selection**: training stage · Compares Naïve Bayes and Random Forest classifiers.
- [Fitted vectorizer](https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/tfidf_vectorizer.pkl): serialized artifact · Defines the inference feature-space contract. · `tfidf_vectorizer.pkl`
- [Selected sentiment model](https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/best_sentiment_model.pkl): serialized artifact · Best-performing trained estimator. · `best_sentiment_model.pkl`
- **Analysis visualizations**: reporting · Sentiment and model-result plots.

### Prediction Runtime

Application-facing inference path.

- [Inference application](https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/app.py): Python entry point · Accepts tweet input and returns a sentiment class. · `app.py`
- **Tweet input**: runtime input
- **Inference preparation**: NLP pipeline · Must preserve training preprocessing assumptions.
- **Sentiment prediction**: classification output · Positive, neutral, or negative.

### Other components

- [Python dependencies](https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/requirements.txt): dependency manifest · Includes spaCy, scikit-learn, Matplotlib, and Seaborn. · `requirements.txt`
- [Development environment](https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/.devcontainer/devcontainer.json): dev container config · Reproducible development setup. · `.devcontainer/devcontainer.json`
- [Presentation assets](https://github.com/kajamalan15/airline-sentiment-analysis-nlp/blob/main/ImageFolder/Images): demo media · Non-production images and video. · `ImageFolder/Images`

## Connections

- Labeled tweets → Training notebook: explored and labeled for training
- Training notebook → Text preprocessing: cleans tweets
- Text preprocessing → TF-IDF features: feeds cleaned text
- TF-IDF features → Model selection: training features
- Model selection → Selected sentiment model: serializes best model
- TF-IDF features → Fitted vectorizer: persists fitted vectorizer
- Training notebook → Analysis visualizations: produces analysis
- Tweet input → Inference application: submitted to
- Inference application → Inference preparation: prepares input
- Fitted vectorizer → Inference application: loads feature contract
- Selected sentiment model → Inference application: loads estimator
- Inference preparation → Sentiment prediction: classifies with loaded artifacts
- Python dependencies → Training notebook: supports training stack
- Python dependencies → Inference application: supports runtime stack
- Development environment → Python dependencies: provisions environment
