Flask REST-Api for getting ML-calculated diamond price predictions based on the provided parameters.
Scrape diamond sales from the big online sellers of loose diamonds, train a price prediction model, and evaluate pricing on unseen constellations of diamond properties. Don't get ripped off by your local jeweller!
I recommend to exclusively train with and consider GIA certified diamonds for more consistent pricing.
Parameters:
Name | Type | Description |
---|---|---|
Shape | String | Diamond shape, Ex: "Round" |
Color | String | Color grade, Ex: "F" |
Clarity | String | Clarity, Ex: "VVS1" |
Cut | String | Cut grade, Ex: "Ideal" |
Carat | Double | Carat weight, Ex: 1.12 |
JSON response:
{
'price_prediction': [predicted price]
}
Parameters:
Name | Type | Description |
---|---|---|
batch | array | List of diamond objects containing all information described in the /single_inference endpoint |
JSON response:
{
'diamond_1': {
'details': {...},
'price_prediction': [predicted price]
},
...
}
Parameters: None
Response: {'success': [True or False]}
-
A database of diamond sales saved as database.csv in
./data/
, preferrably at least 10'000 sales. For structure, see example in scraper.py. -
Tensorflow Keras
,sklearn
,flask
packages installed
- regression_estimator.h5 in
./model/
. This is exported automatically when training the model.
- Clone the repo
- Run main.py
- Send requests to
localhost:5000
and enjoy!
Model performance is very much dependent on the training data available. I have uploaded a small sample dataset of 20'000 diamond sales which you are welcome to use, but for increased performance I would recommend scraping your own larger dataset than that.
This prediction model was trained on 50'000 sales.
Request: GET with payload
{Shape: "Emerald", Color: "J", Clarity: "VS2", Cut: "Ideal", Carat: "1.5"}
Response: {price_prediction: 6865.705}
Reality:
This prediction is within +-1% of the only actual diamond I found with these exact properties!