Skip to main content

Price predictions for 3DHubs

Project description

Price Prediction

Start Predicting

  • Install the package:

    pip install hubs-predictor
    
  • How to Use:

    from hubs_predictor import predict_batch, predict_from_csv
    
    # IP = 'localhost' if the container is running locally
    IP = '164.52.192.139' # Hosted in my private server for quick testing
    
    # Predict using CSV file:
    csv_path = '/PATH/TO/YOUR/CSV/FILE.csv'
    result = predict_from_csv(csv_path, ip=IP)
    
    # Predict as list batches
    # input format should be list of list [[], []]
    # eg: data = [['2015-01-09 23:15:03.308', 'cart__4', '27.917', '86.632', '11.022', '247384.01', ....., 'supplier__054'],
    #             ['2015-01-10 24:15:03.308', 'cart__5', '17.917', '76.632', '10.022', '147384.01', ....., 'supplier__055']]
    data = [[value1, value2, ...., value16],
            [value1, value2, ...., value16]]
    result = predict_batch(data, ip=IP)
    
    # NOTE: The input data both `csv_file` and `data` should be in the same feature sequence provided in the 'assignment-data.csv'
    # i.e: ['timestamp', 'cart', 'geometry/bounding_box/depth', 'geometry/bounding_box/width', ......., 'sourcing/supplier_country', 'sourcing/supplier']
    # which is 16 columns excluding `target/price`, if `target/price` is provided,  it will be ignored internally.
    

    Check Example script: test_package_example.py for more clarification.

    To build and setup local container please check Replicate / Reproduce Whole Process see below.


Replicate / Reproduce Whole Process

Training Process

  • Pre-requirements:

    1. Install conda: link
    2. Install MLFlow:
      pip install mlflow
      
  • Extract Data: assignment-data.zip to train/data/

    unzip assignment-data.zip -d train/data/
    
  • Run Mlflow UI server to track the training experiments:

    cd train/
    mlflow server --backend-store-uri ./mlruns/ &
    
    # open 'http://localhost:5000/' to see the experiments
    # To stop mlflow server use `pkill -f mlflow`
    
  • Train:

    # working dir: "ml-engineer-assignment-bendangnuksung/train/"
    
    # (OPTIONAL) modify "train/MLproject" file, update parameters such as:
    # 'datapath' -> path to your data CSV file
    # 'kfolds'   -> N kfolds you want
    # 'lr'       -> Set your own learning rate
    
    # Run training 
    mlflow run --experiment-name hubs_price_prediction .
    

Deployment Process

  • Pre-requirements:

    1. Install Docker. Link
    2. Install Docker Compose:
      pip install docker-compose
      
  • Build and Start Docker:

    # working dir: "ml-engineer-assignment-bendangnuksung/"
    
    # (OPTIONAL) Modify "docker-compose.yml" if:
    # 1. Wants to change PORT
    # 2. Change the volumes if model stored in different directory. (Default is: "./train/models" because models are stored there after training) 
    
    docker-compose up
    
  • Building package (Optional):

    # modify setup.py accordingly
    python setup.py sdist
    python setup.py bdist_wheel
    twine check dist/*
    twine upload dist/*
    

Now the docker container is Up and Running, you can run the models locally. Just assign IP = 'localhost'

from hubs_predictor import predict_batch, predict_from_csv
IP = 'localhost'
csv_path = '/PATH/TO/YOUR/CSV/FILE.csv'
result = predict_from_csv(csv_path, ip=IP)
result = predict_batch(data, ip=IP)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hubs_predictor-0.1.2.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

hubs_predictor-0.1.2-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page