Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Product Classification

A machine learning system that classifies products into categories based on their names and brands.

What it does

Takes a product name and brand, predicts which category it belongs to. Built with scikit-learn, PyTorch, and FastAPI.

Train the models:

pip install -r requirements.txt
python run_pipeline.py

Start the API:

python app.py
# Visit http://localhost:8000/docs

Make a prediction:

curl -X POST "http://localhost:8000/classify" \
  -H "Content-Type: application/json" \
  -d '{"product_id": "123", "name": "Chanel No 5 Eau De Parfum", "brand": "Chanel"}'

With Docker:

docker build -t product-classifier .
docker run -p 8000:8000 product-classifier

Project Structure

β”œβ”€β”€ app.py                    # FastAPI application
β”œβ”€β”€ run_pipeline.py           # Train models
β”œβ”€β”€ run_tests.py              # Run tests
β”œβ”€β”€ src/                      # ML code
β”œβ”€β”€ tests/                    # Test suite
β”œβ”€β”€ data/                     # Dataset
β”œβ”€β”€ models/                   # Trained models
β”œβ”€β”€ images/                   # Plots and visualizations
└── docs/                     # Additional documentation

Models

Three models trained on product names and brands:

  • Random Forest: 73% test accuracy (best performer)
  • PyTorch Neural Network: 71% test accuracy
  • Logistic Regression: 49% test accuracy (baseline)

The Random Forest model is used in the API.

API Endpoints

  • GET / - API info
  • GET /health - Health check
  • POST /classify - Classify a single product
  • POST /classify/batch - Classify multiple products

Interactive docs at http://localhost:8000/docs

Testing

python run_tests.py

Tech Stack

  • scikit-learn, PyTorch
  • FastAPI
  • pandas, numpy
  • Docker

Notes

The dataset is small (~180 training samples, 60 categories), which limits model performance. With more data, accuracy would improve significantly.

See docs/ folder for detailed documentation on the ML pipeline, API usage, and Docker deployment.

About

🏷️ ML product classification API β€” scikit-learn, PyTorch & FastAPI with Docker

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages