Skip to content

Litou-lyh/dbs-webapp-24su

 
 

Repository files navigation

DBS Project: End-to-end Insurance Cost Prediction Application

Build Status Open in Remote - Containers

This repository is the code of Final Project (part4) for course Database Systems by Prof. Jean-Claude Franchitti. We have deploy the application using Microsoft Azure Cloud Service at here. Please feel free to try out!

The code is using Flask micro-framework. It also uses PostgreSQL as a database. Input data will be passed through RestFUL API for backend processing. CRUD operations are implemented using Object–Relational Mapping (ORM), and data is then stored in PostgreSQL database. We integreated an XGBoost model for insurance cost prediction. The prediction function is also called by RestFUL API.

This repository is based on a lab from the NYU DevOps and Agile Methodologies graduate course CSCI-GA.2820-001 on Behavior Driven Development with Flask and Behave

Introduction

Many enterprises still rely on structured data in traditional relational databases and data warehouses. However, to drive business growth, digital transformation, and enhance user experience and organizational excellence, they need real-time insights. To achieve this, enterprises are developing additional data sources to manage large amounts of unstructured data, enabling semi real-time big data analytics and the creation of machine/deep learning and AI digital solutions.

We try to build a project following this idea, and provide a end-to-end web app integrating relational database and ML models.

In this project, We focus on the business use case of insurance cost prediction: customer's health condition and daily habits are significant indicators to their insurance cost, and insurance companies rely heavily on precise prediction models to provide appropriate insurance policies and products. With machine learning models, for insurance companies, we help them accelerate cost assessment procedures, and lower their risks on unpredicted insurance claims; for customers, we help them get their suitable insurance products.

What's featured in the project?

./service/routes.py -- the main Service using Python Flask
./service/models.py -- the data models for persistence
./service/common -- a collection of status, error handlers and logging setup
./tests/test_routes.py -- unit test cases for the server
./tests/test_models.py -- unit test cases for the model

Instruction of deployment and usage

Deployment

Pull the Docker Image

docker pull gorgeous/dbs-webapp-24su:v6

Run It Locally

docker docker run --rm -p 8080:8080 --platform linux/amd64 gorgeous/dbs-webapp-24su:v6

Now you can access in your browser with this URL: http://localhost:8080/

Deployment using Microsoft Azure Cloud Service

We have deploy the application using Microsoft Azure Cloud Service at here. Please feel free to try out!

User guide

  • To Create a health record:

    1. Fill out the form with valid data. (Leave Record ID blank; age must be positive integer; BMI must be positive number)
    2. Click "Create" button.
    3. Wait the record id appears in the form, together with a flash message says "success"
  • To Retrieve a health record:

    1. Enter record id.
    2. Click "Retrieve" button.
    3. If succcess: all the fields will be filled with data, If fail: flash message says "404 Not Found"
  • To Update a health record:

    1. Fill out the form with valid data, including Record ID of the record you want to modify.
    2. Click "Update" button.
    3. If success, then a flash message says "success". If you retrieve the record later, the fields will be updated.
  • To Delete a health record:

    1. Enter record id.
    2. Click "Delete" button.
    3. If succcess: then a flash message says "Record has been Deleted!"; If the record does not exist: then a flash message says "Server error!"
  • To predict the cost of a health record:

    1. After you create the record !!!
    2. Enter the record id.
    3. Click "Predict" button.
    4. If succcess: then a flash message says "Success" and the predicted results will be displayed in the result table below.
      • Cost: predicted insurance cost
      • Suggestion: suggestions to the insurance operator. (Accept, Conditional Accept, and Refuse)
      • Plan: different level of plans could be applied. (Normal, Enhanced Version, Extra Condition Version, and Only Endorsed by Manager)

homepage

Figure 1: Homepage


create_record

Figure 2: Create Record


example_of_invalid_data

Figure 3: Example of Invalid Data


prediction

Figure 4: Prediction


example_of_refuse

Figure 5: Example of Refuse

License

Copyright (c) 2016, 2024, John J. Rofrano. All rights reserved.

Licensed under the Apache License. See LICENSE

This repository is part of the NYU graduate class CSCI-GA.2810-001: DevOps and Agile Methodologies taught by John Rofrano, Adjunct Instructor, NYU Courant Institute, Graduate Division, Computer Science.

About

Database Systems project e2e webapp. Based on NYU DevOps lab Template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 58.3%
  • JavaScript 16.9%
  • HTML 11.1%
  • Makefile 5.9%
  • Shell 4.9%
  • Dockerfile 2.8%
  • Procfile 0.1%