# abhadimishra/sentiment_classification_modelling architecture

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

- Interactive diagram: https://gitdiagram.com/abhadimishra/sentiment_classification_modelling
- Repository: https://github.com/abhadimishra/sentiment_classification_modelling

## Overview

#### Purpose and scope
This is a notebook-driven Python machine-learning project for sentiment classification of chat text, including WhatsApp-style chat analysis. It trains multiple TF-IDF-based classifiers, compares evaluation metrics, persists selected models, and applies a trained model to random or extracted chat messages.

#### Entry points
- Training and model comparison: `Models_Check.ipynb` (the README calls this `Model_Check.ipynb`; the repository file is plural).
- Inference/testing workflow: `Testing_on_random_chat.ipynb`.
- Dataset input: `Chat_for_train.csv`.
- Repository-level usage and reported model metrics: `README.md`.

#### Data ingestion and preparation
`Chat_for_train.csv` is the required training-data boundary. The training notebook is responsible for loading labeled chat text and preparing it for classification. The README also describes extracting messages from WhatsApp chat data, but no standalone extraction script or raw WhatsApp export is present; that logic, if implemented, resides in the notebooks.

Paths:
- `Chat_for_train.csv`
- `Models_Check.ipynb`
- `Testing_on_random_chat.ipynb`

#### Feature representation
The core representation is TF-IDF vectorization of message text. This transforms raw chat messages into numeric sparse features consumed by every downstream classifier. Persisted artifacts described in the README use names such as `pipeline_svm.joblib`, implying vectorization and model steps may be packaged together as sklearn-style pipelines, although these artifact files are not present in the supplied tree.

Paths:
- `Models_Check.ipynb`
- `README.md`

#### Training and model-selection stage
The training notebook evaluates nine supervised classifiers: Multinomial Naive Bayes, Logistic Regression, SVC, Random Forest, KNN, Decision Tree, MLP, Gradient Boosting, and AdaBoost. Metrics drive comparison: accuracy, F1, and precision. README-reported performance identifies SVM as the strongest listed model by accuracy (0.73), narrowly ahead of logistic regression (0.72).

Paths:
- `Models_Check.ipynb`
- `README.md`

#### Model artifact boundary
Training is intended to serialize trained estimators into Joblib files for reuse, including `pipeline_mnb.joblib`, `logistic_reg.joblib`, and `pipeline_svm.joblib`. These models are a contract between the training notebook and testing notebook: inference must use the same fitted TF-IDF vocabulary/transformer as training. The files are documented but absent from the current file tree, so reproducing inference likely requires running training first.

Paths:
- `Models_Check.ipynb`
- `Testing_on_random_chat.ipynb`
- `README.md`

#### Inference flow
The testing notebook loads a pre-trained classifier, receives individual chat messages or parsed WhatsApp messages, applies the trained text preprocessing/vectorization path, and outputs sentiment predictions. It is an offline notebook workflow, not a deployed service or web application.

Paths:
- `Testing_on_random_chat.ipynb`
- `README.md`

#### Runtime and infrastructure
The material runtime is local Python 3.x with notebook execution. The implied ML stack is scikit-learn for TF-IDF, classifiers, evaluation, and Joblib persistence. There is no server, database, cloud infrastructure, API, CI pipeline, or external service represented in the repository tree.

Paths:
- `README.md`
- `Models_Check.ipynb`

Main entry points: [`Models_Check.ipynb`](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb) (Model comparison notebook), [`Testing_on_random_chat.ipynb`](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Testing_on_random_chat.ipynb) (Chat testing notebook), [`README.md`](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/README.md) (Usage & metrics), [`Chat_for_train.csv`](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Chat_for_train.csv) (Labeled chat dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training &amp; Selection"]
  node_training_data[("Labeled chat dataset<br/>CSV dataset<br/>[Chat_for_train.csv]")]
  node_training_notebook["Model comparison notebook<br/>Jupyter notebook<br/>[Models_Check.ipynb]"]
  node_text_preparation["Text preparation<br/>preprocessing stage<br/>[Models_Check.ipynb]"]
  node_tfidf["TF-IDF features<br/>sparse feature layer<br/>[Models_Check.ipynb]"]
  node_classifier_suite["Nine classifiers<br/>sklearn model suite<br/>[Models_Check.ipynb]"]
  node_evaluation["Metric comparison<br/>evaluation stage<br/>[Models_Check.ipynb]"]
  node_selected_model["Selected SVM<br/>selected classifier<br/>[README.md]"]
end

subgraph group_inference["Offline Inference"]
  node_testing_notebook["Chat testing notebook<br/>Jupyter notebook"]
  node_chat_messages["Input chat messages<br/>message input"]
  node_loaded_pipeline["Loaded trained pipeline<br/>sklearn inference pipeline"]
  node_sentiment_predictions["Sentiment predictions<br/>classification output"]
end

node_joblib_artifacts["Joblib model artifacts<br/>artifact contract<br/>[README.md]"]
node_project_documentation["Usage &amp; metrics<br/>README<br/>[README.md]"]
node_local_runtime["Local Python notebook runtime<br/>Python / scikit-learn<br/>[Models_Check.ipynb]"]

node_training_data -->|"loaded by"| node_training_notebook
node_training_notebook -->|"prepares text"| node_text_preparation
node_text_preparation -->|"vectorized as"| node_tfidf
node_tfidf -->|"features for"| node_classifier_suite
node_classifier_suite -->|"evaluated with"| node_evaluation
node_evaluation -->|"selects"| node_selected_model
node_selected_model -->|"serialized to"| node_joblib_artifacts
node_joblib_artifacts -->|"loaded by"| node_loaded_pipeline
node_chat_messages -->|"provided to"| node_testing_notebook
node_testing_notebook -->|"uses"| node_loaded_pipeline
node_loaded_pipeline -->|"predicts"| node_sentiment_predictions
node_project_documentation -.->|"documents"| node_training_notebook
node_project_documentation -.->|"documents"| node_testing_notebook
node_local_runtime -->|"executes"| node_training_notebook
node_local_runtime -->|"executes"| node_testing_notebook

click node_training_data "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Chat_for_train.csv"
click node_training_notebook "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb"
click node_text_preparation "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb"
click node_tfidf "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb"
click node_classifier_suite "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb"
click node_evaluation "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb"
click node_selected_model "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/README.md"
click node_joblib_artifacts "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/README.md"
click node_testing_notebook "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Testing_on_random_chat.ipynb"
click node_chat_messages "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Testing_on_random_chat.ipynb"
click node_loaded_pipeline "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Testing_on_random_chat.ipynb"
click node_sentiment_predictions "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Testing_on_random_chat.ipynb"
click node_project_documentation "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/README.md"
click node_local_runtime "https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb"

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_training_notebook,node_text_preparation,node_tfidf,node_classifier_suite,node_evaluation,node_selected_model toneBlue
class node_testing_notebook,node_chat_messages,node_loaded_pipeline,node_sentiment_predictions toneAmber
class node_joblib_artifacts,node_project_documentation,node_local_runtime toneNeutral
```

## Components

### Training & Selection

- [Labeled chat dataset](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Chat_for_train.csv): CSV dataset · Required labeled-text input. · `Chat_for_train.csv`
- [Model comparison notebook](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb): Jupyter notebook · Loads data, trains and compares classifiers. · `Models_Check.ipynb`
- [Text preparation](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb): preprocessing stage · `Models_Check.ipynb`
- [TF-IDF features](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb): sparse feature layer · Shared representation for all classifiers. · `Models_Check.ipynb`
- [Nine classifiers](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb): sklearn model suite · MNB, logistic regression, SVC, random forest, KNN, decision tree, MLP, gradient boosting, and AdaBoost. · `Models_Check.ipynb`
- [Metric comparison](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb): evaluation stage · Compares accuracy, F1, and precision. · `Models_Check.ipynb`
- [Selected SVM](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/README.md): selected classifier · README reports SVM as highest accuracy (0.73). · `README.md`

### Offline Inference

- [Chat testing notebook](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Testing_on_random_chat.ipynb): Jupyter notebook · Offline workflow for random or parsed WhatsApp messages. · `Testing_on_random_chat.ipynb`
- [Input chat messages](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Testing_on_random_chat.ipynb): message input · Individual or parsed WhatsApp-style text. · `Testing_on_random_chat.ipynb`
- [Loaded trained pipeline](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Testing_on_random_chat.ipynb): sklearn inference pipeline · Applies training-compatible preprocessing and vectorization. · `Testing_on_random_chat.ipynb`
- [Sentiment predictions](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Testing_on_random_chat.ipynb): classification output · `Testing_on_random_chat.ipynb`

### Other components

- [Joblib model artifacts](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/README.md): artifact contract · Persisted pipeline must retain the fitted TF-IDF transformer. · `README.md`
- [Usage & metrics](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/README.md): README · Documents workflow, extraction context, and reported results. · `README.md`
- [Local Python notebook runtime](https://github.com/abhadimishra/sentiment_classification_modelling/blob/main/Models_Check.ipynb): Python / scikit-learn · No deployed service or external infrastructure. · `Models_Check.ipynb`

## Connections

- Labeled chat dataset → Model comparison notebook: loaded by
- Model comparison notebook → Text preparation: prepares text
- Text preparation → TF-IDF features: vectorized as
- TF-IDF features → Nine classifiers: features for
- Nine classifiers → Metric comparison: evaluated with
- Metric comparison → Selected SVM: selects
- Selected SVM → Joblib model artifacts: serialized to
- Joblib model artifacts → Loaded trained pipeline: loaded by
- Input chat messages → Chat testing notebook: provided to
- Chat testing notebook → Loaded trained pipeline: uses
- Loaded trained pipeline → Sentiment predictions: predicts
- Usage & metrics → Model comparison notebook: documents
- Usage & metrics → Chat testing notebook: documents
- Local Python notebook runtime → Model comparison notebook: executes
- Local Python notebook runtime → Chat testing notebook: executes
