# minahilirfan98/datascience-ai architecture

> Architecture diagram of the GitHub repository minahilirfan98/datascience-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/minahilirfan98/datascience-ai
- Repository: https://github.com/minahilirfan98/datascience-ai

## Overview

This repository includes coursework materials and a small Twitter sentiment-analysis application. Its user workflow is: enter tweet text in Gradio, preprocess it, transform it with the saved TF-IDF vectorizer, classify it with the saved Logistic Regression model, then display a sentiment label and confidence. A separate training script prepares data, trains and evaluates the model, and saves the two artifacts. The training CSV is referenced by the script but is absent from the tree; the README is empty.

Main entry points: [`twitter-sentiment-analysis/app.py`](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py) (Prediction handler), [`twitter-sentiment-analysis/trainmodel.py`](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py) (Training workflow), [`twitter-sentiment-analysis/model.pkl`](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/model.pkl) (Model artifact), [`twitter-sentiment-analysis/vectorizer.pkl`](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/vectorizer.pkl) (Vectorizer artifact)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model training"]
  node_training_data["Training CSV"]
  node_trainer["Training workflow<br/>[trainmodel.py]"]
  node_train_clean["Text cleaning<br/>[trainmodel.py]"]
  node_tfidf_fit["TF-IDF fitting<br/>[trainmodel.py]"]
  node_split["Train-test split<br/>[trainmodel.py]"]
  node_train_model["Logistic regression<br/>[trainmodel.py]"]
  node_evaluation["Model evaluation<br/>[trainmodel.py]"]
  node_model_artifact["Model artifact<br/>[model.pkl]"]
  node_vectorizer_artifact["Vectorizer artifact<br/>[vectorizer.pkl]"]
end

subgraph group_inference["Prediction"]
  node_predict["Prediction handler<br/>[app.py]"]
  node_app_clean["Text cleaning<br/>[app.py]"]
  node_transform["TF-IDF transform<br/>[app.py]"]
  node_classify["Classification and confidence<br/>[app.py]"]
  node_label_map["Sentiment labels<br/>[app.py]"]
end

subgraph group_interface["User interface"]
  node_gradio["Gradio interface<br/>[app.py]"]
  node_result["Prediction display<br/>[app.py]"]
end

node_user(("Tweet submitter"))

node_training_data -->|"reads"| node_trainer
node_trainer -->|"cleans text"| node_train_clean
node_train_clean -->|"fits features"| node_tfidf_fit
node_tfidf_fit -->|"splits features"| node_split
node_split -->|"trains model"| node_train_model
node_train_model -->|"evaluates"| node_evaluation
node_trainer -->|"saves"| node_model_artifact
node_trainer -->|"saves"| node_vectorizer_artifact
node_user -->|"enters tweet"| node_gradio
node_gradio -->|"invokes"| node_predict
node_predict -->|"preprocesses"| node_app_clean
node_predict -->|"transforms text"| node_transform
node_transform -->|"uses"| node_vectorizer_artifact
node_predict -->|"predicts"| node_classify
node_classify -->|"uses"| node_model_artifact
node_predict -->|"maps class"| node_label_map
node_predict -->|"formats result"| node_result
node_gradio -->|"displays"| node_result

click node_trainer "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py"
click node_train_clean "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py"
click node_tfidf_fit "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py"
click node_split "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py"
click node_train_model "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py"
click node_evaluation "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py"
click node_model_artifact "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/model.pkl"
click node_vectorizer_artifact "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/vectorizer.pkl"
click node_gradio "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py"
click node_predict "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py"
click node_app_clean "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py"
click node_transform "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py"
click node_classify "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py"
click node_label_map "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py"
click node_result "https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py"

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_training_data,node_trainer,node_train_clean,node_tfidf_fit,node_split,node_train_model,node_evaluation,node_model_artifact,node_vectorizer_artifact toneBlue
class node_predict,node_app_clean,node_transform,node_classify,node_label_map toneAmber
class node_gradio,node_result toneMint
class node_user toneIndigo
```

## Components

### Model training

- **Training CSV**
- [Training workflow](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py): `twitter-sentiment-analysis/trainmodel.py`
- [Text cleaning](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py): `twitter-sentiment-analysis/trainmodel.py`
- [TF-IDF fitting](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py): `twitter-sentiment-analysis/trainmodel.py`
- [Train-test split](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py): `twitter-sentiment-analysis/trainmodel.py`
- [Logistic regression](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py): `twitter-sentiment-analysis/trainmodel.py`
- [Model evaluation](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/trainmodel.py): `twitter-sentiment-analysis/trainmodel.py`
- [Model artifact](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/model.pkl): `twitter-sentiment-analysis/model.pkl`
- [Vectorizer artifact](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/vectorizer.pkl): `twitter-sentiment-analysis/vectorizer.pkl`

### Prediction

- [Prediction handler](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py): `twitter-sentiment-analysis/app.py`
- [Text cleaning](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py): `twitter-sentiment-analysis/app.py`
- [TF-IDF transform](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py): `twitter-sentiment-analysis/app.py`
- [Classification and confidence](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py): `twitter-sentiment-analysis/app.py`
- [Sentiment labels](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py): `twitter-sentiment-analysis/app.py`

### User interface

- [Gradio interface](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py): `twitter-sentiment-analysis/app.py`
- [Prediction display](https://github.com/minahilirfan98/datascience-ai/blob/main/twitter-sentiment-analysis/app.py): `twitter-sentiment-analysis/app.py`

### Other components

- **Tweet submitter**

## Connections

- Training CSV → Training workflow: reads (evidence: `twitter-sentiment-analysis/trainmodel.py`)
- Training workflow → Text cleaning: cleans text (evidence: `twitter-sentiment-analysis/trainmodel.py`)
- Text cleaning → TF-IDF fitting: fits features (evidence: `twitter-sentiment-analysis/trainmodel.py`)
- TF-IDF fitting → Train-test split: splits features (evidence: `twitter-sentiment-analysis/trainmodel.py`)
- Train-test split → Logistic regression: trains model (evidence: `twitter-sentiment-analysis/trainmodel.py`)
- Logistic regression → Model evaluation: evaluates (evidence: `twitter-sentiment-analysis/trainmodel.py`)
- Training workflow → Model artifact: saves (evidence: `twitter-sentiment-analysis/trainmodel.py`)
- Training workflow → Vectorizer artifact: saves (evidence: `twitter-sentiment-analysis/trainmodel.py`)
- Tweet submitter → Gradio interface: enters tweet (evidence: `twitter-sentiment-analysis/app.py`)
- Gradio interface → Prediction handler: invokes (evidence: `twitter-sentiment-analysis/app.py`)
- Prediction handler → Text cleaning: preprocesses (evidence: `twitter-sentiment-analysis/app.py`)
- Prediction handler → TF-IDF transform: transforms text (evidence: `twitter-sentiment-analysis/app.py`)
- TF-IDF transform → Vectorizer artifact: uses (evidence: `twitter-sentiment-analysis/app.py`)
- Prediction handler → Classification and confidence: predicts (evidence: `twitter-sentiment-analysis/app.py`)
- Classification and confidence → Model artifact: uses (evidence: `twitter-sentiment-analysis/app.py`)
- Prediction handler → Sentiment labels: maps class (evidence: `twitter-sentiment-analysis/app.py`)
- Prediction handler → Prediction display: formats result (evidence: `twitter-sentiment-analysis/app.py`)
- Gradio interface → Prediction display: displays (evidence: `twitter-sentiment-analysis/app.py`)
