An end-to-end machine learning project
Books are the most important friends in one’s life. Books are open doors to the unimagined worlds which is unique to every person. It is more than just a hobby for many. There are many among us who prefer to spend more time with books than anything else. Here we explore a database of books. Books of different genres, from various authors.
The web app is intended for predicting book prices from bookdepository.com. Model was trained on the predefined and cleaned dataset: https://github.com/fortune-uwha/book_scraper and can predict price by given parameters. Trained model is saved to model.pkl file.
- Create Heroku project and Heroku PostgreSQL database
- Add your database credentials to .env file (make sure to rename .env_template to .env)
- Clone the repository and create a virtualenv.
- Run
pip install -r requirements.txt
to install project requirements - Type
flask run
to start the app
The API endpoint is a Flask app hosted on heroku https://books-price-prediction.herokuapp.com/predict which you can access with any REST API client, such as Postman. There is only one main route:
- /predict - takes POST requests, predicts price by parameters provided.
- /history - takes GET requests and returns last 10 most recent requests and predictions from the database
- /history/amount - you can supply an optional number of results to return by adding an int amount, for example https://books-price-prediction.herokuapp.com/history/5
{
"author": "Bethany Roberts",
"edition": "Hardback",
"category": "Medical"
}
You can also use requests module and use the API in a Jupyter notebook to view history like this:
import json
import requests
url = 'https://books-price-prediction.herokuapp.com/history'
response = requests.get(url, data=json.dumps(json_input))
print (f"response: {json.loads(response.content)}")
Project is: in progress
This project was based on Turing College learning on building an end-to-end-machine learning project.
Created by @fortune_uwha - feel free to contact me!
Feel free to submit an issue with your ideas or comments. I will be happy to see your way of scaffolding Flask applications.
This project is open source and available under the terms of the MIT license.