Skip to content

An end-to-end machine learning project: Flask app hosted on heroku

License

Notifications You must be signed in to change notification settings

fortune-uwha/books-price-prediction

Repository files navigation

Books Depository Price Prediction App

Python 3.6 Python 3.7 Python 3.8 License: MIT Issues: 0 An end-to-end machine learning project

Table of Contents

General Information

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.

Setup

  • 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

Usage

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

Input json format example:

{
    "author": "Bethany Roberts",
    "edition": "Hardback",
    "category": "Medical"
}

Postman usage example:

Using Jupyter Notebook

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 Status

Project is: in progress

Acknowledgements

This project was based on Turing College learning on building an end-to-end-machine learning project.

Contact

Created by @fortune_uwha - feel free to contact me!

Contributing

Feel free to submit an issue with your ideas or comments. I will be happy to see your way of scaffolding Flask applications.

License

This project is open source and available under the terms of the MIT license.

About

An end-to-end machine learning project: Flask app hosted on heroku

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published