# b3thowen/product-category-classifier architecture

> Architecture diagram of the GitHub repository b3thowen/product-category-classifier, 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/b3thowen/product-category-classifier
- Repository: https://github.com/b3thowen/product-category-classifier

## Overview

This repository is a product-title category classifier. Its main workflow is to enter a title in the interactive CLI, load the saved sklearn pipeline, and return a predicted category with an optional decision-score margin. A separate training workflow cleans labeled product data, evaluates a holdout model, then fits and saves the final model. The README also documents notebook-based analysis and comparison of four algorithms. Training and prediction calls are visible in the sampled scripts; notebook internals were not inspected.

Main entry points: [`train_model.py`](https://github.com/b3thowen/product-category-classifier/blob/main/train_model.py) (Training script), [`predict_category.py`](https://github.com/b3thowen/product-category-classifier/blob/main/predict_category.py) (Interactive CLI), [`model_utils.py`](https://github.com/b3thowen/product-category-classifier/blob/main/model_utils.py) (Data cleaning), [`products.csv`](https://github.com/b3thowen/product-category-classifier/blob/main/products.csv) (Product data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_dataset[("Product data<br/>[products.csv]")]
  node_cleaning["Data cleaning<br/>[model_utils.py]"]
  node_features["Title features<br/>[model_utils.py]"]
end

subgraph group_training["Model training"]
  node_analysis["Model analysis"]
  node_trainer["Training script<br/>[train_model.py]"]
  node_pipeline["SVC pipeline<br/>[train_model.py]"]
  node_evaluation["Holdout evaluation<br/>[train_model.py]"]
  node_model[("Saved model")]
end

subgraph group_prediction["Prediction"]
  node_cli["Interactive CLI"]
  node_prediction["Category prediction"]
  node_result["Predicted category"]
end

node_user(("CLI user"))

node_dataset -->|"provides rows"| node_cleaning
node_trainer -->|"loads and cleans"| node_cleaning
node_trainer -->|"configures"| node_features
node_features -->|"transforms titles"| node_pipeline
node_cleaning -->|"returns data"| node_trainer
node_trainer -->|"fits"| node_pipeline
node_trainer -->|"evaluates holdout"| node_evaluation
node_pipeline -->|"saves final fit"| node_model
node_analysis -->|"analyzes"| node_dataset
node_user -->|"enters title"| node_cli
node_cli -->|"loads"| node_model
node_cli -->|"calls"| node_prediction
node_prediction -->|"returns category"| node_result

click node_dataset "https://github.com/b3thowen/product-category-classifier/blob/main/products.csv"
click node_cleaning "https://github.com/b3thowen/product-category-classifier/blob/main/model_utils.py"
click node_features "https://github.com/b3thowen/product-category-classifier/blob/main/model_utils.py"
click node_analysis "https://github.com/b3thowen/product-category-classifier/blob/main/product_category_analysis.ipynb"
click node_trainer "https://github.com/b3thowen/product-category-classifier/blob/main/train_model.py"
click node_pipeline "https://github.com/b3thowen/product-category-classifier/blob/main/train_model.py"
click node_evaluation "https://github.com/b3thowen/product-category-classifier/blob/main/train_model.py"
click node_model "https://github.com/b3thowen/product-category-classifier/blob/main/product_category_model.pkl"
click node_cli "https://github.com/b3thowen/product-category-classifier/blob/main/predict_category.py"
click node_prediction "https://github.com/b3thowen/product-category-classifier/blob/main/predict_category.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_dataset,node_cleaning,node_features,node_user toneBlue
class node_analysis,node_trainer,node_pipeline,node_evaluation,node_model toneAmber
class node_cli,node_prediction,node_result toneMint
```

## Components

### Data preparation

- [Product data](https://github.com/b3thowen/product-category-classifier/blob/main/products.csv): `products.csv`
- [Data cleaning](https://github.com/b3thowen/product-category-classifier/blob/main/model_utils.py): `model_utils.py`
- [Title features](https://github.com/b3thowen/product-category-classifier/blob/main/model_utils.py): `model_utils.py`

### Model training

- [Model analysis](https://github.com/b3thowen/product-category-classifier/blob/main/product_category_analysis.ipynb): `product_category_analysis.ipynb`
- [Training script](https://github.com/b3thowen/product-category-classifier/blob/main/train_model.py): `train_model.py`
- [SVC pipeline](https://github.com/b3thowen/product-category-classifier/blob/main/train_model.py): `train_model.py`
- [Holdout evaluation](https://github.com/b3thowen/product-category-classifier/blob/main/train_model.py): `train_model.py`
- [Saved model](https://github.com/b3thowen/product-category-classifier/blob/main/product_category_model.pkl): `product_category_model.pkl`

### Prediction

- [Interactive CLI](https://github.com/b3thowen/product-category-classifier/blob/main/predict_category.py): `predict_category.py`
- [Category prediction](https://github.com/b3thowen/product-category-classifier/blob/main/predict_category.py): `predict_category.py`
- **Predicted category**

### Other components

- **CLI user**

## Connections

- Product data → Data cleaning: provides rows (evidence: `README.md`)
- Training script → Data cleaning: loads and cleans (evidence: `train_model.py`)
- Training script → Title features: configures (evidence: `train_model.py`)
- Title features → SVC pipeline: transforms titles (evidence: `train_model.py`)
- Data cleaning → Training script: returns data (evidence: `train_model.py`)
- Training script → SVC pipeline: fits (evidence: `train_model.py`)
- Training script → Holdout evaluation: evaluates holdout (evidence: `train_model.py`)
- SVC pipeline → Saved model: saves final fit (evidence: `train_model.py`)
- Model analysis → Product data: analyzes (evidence: `README.md`)
- CLI user → Interactive CLI: enters title (evidence: `README.md`)
- Interactive CLI → Saved model: loads (evidence: `predict_category.py`)
- Interactive CLI → Category prediction: calls (evidence: `predict_category.py`)
- Category prediction → Predicted category: returns category (evidence: `predict_category.py`)
