Skip to content

onidzelskyi/python_product_category_classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Product Category Classification Model

Project' structure

docs/
    Simple_Product_Category_Classification.ipynb    Ipython notebook with samples and tutorials

prod_classify/
    __init__.py                                     Package file
    core.py                                         Implementation of product category classification model
    endpoints.py                                    Implementation of RESTful application endpoints.

resources/
    bad_csv_content.csv                             Data for tests
    bad_json_content.json                           Data for tests
    model.pickle                                    Data for tests
    Products.csv                                    Train dataset
    test_set.csv                                    Data for tests
    train_set.csv                                   Data for tests
    train_set.json                                  Data for tests

tests/
    test_prod_classify.py                           Tests of product category classification model

main.py                 REST service

LICENSE                 License file

README.md               this file with short description of project

requirements.txt        Requirements of libraries and packages

setup.py                Setup file for package installation

Environment setup

Install virtualenv

sudo apt install python-pip
pip install virtualenvwrapper

Add next lines to /.bashrc (/.profile)

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel

# load virtualenvwrapper for python (after custom PATHs)
venvwrap="virtualenvwrapper.sh"
/usr/bin/which $venvwrap
if [ $? -eq 0 ]; then
    venvwrap=`/usr/bin/which $venvwrap`
    source $venvwrap
fi

Run script

. ~/.local/bin/virtualenvwrapper.sh

Create virtual environment

mkvirtualenv -p python3.5 prod_classify

Install dependencies

pip install -r requirements.txt

install the package locally (for use on our system)

pip install -e .

Run tests

pytest tests

Run demo app

python main.py

Train model from CSV file

curl -F file=@resources/train_set.csv localhost:5000/fit

Train model from JSON data

curl -X POST -H "Content-Type: application/json" localhost:5000/fit -d @resources/train_set.json

Predict product' category

curl -X POST -H "Content-Type: application/json" localhost:5000/predict -d '{"products": {"101": "best"}}'

Get model statistics (accuracy)

curl -X POST localhost:5000/statistics -F file=@resources/test_set.csv

Dump model to default file

curl -X GET localhost:5000/dump

Dump model to given file

curl -X GET localhost:5000/dump?file=abc.txt

Check PEP008 code style

flake8  --max-line-length=120 .

About

Python product category classification

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages