Giter VIP home page Giter VIP logo

ids721-group-project's Introduction

IDS721 Group-Final-Project Chinese Population Predictor

In this project, we used regression model and imported dataset from kaggle to train it. We used Flask to build a light-weight web framework to predict the future population in China. And then we deploy our service in GCP and used locust to load test it.

The introduction video of our project: https://youtu.be/zTXA0Jn-ezI

Architecture

Screen Shot 2022-04-12 at 9 53 13 PM

How to Run the App

  1. Clone the repo
[email protected]:xzhnshng/IDS721-group-project.git
  1. Create & enter python virtual environment
# first cd to the project directory
# create virtual environment
python -m venv env

# enter the virtual environment
source env/bin/activate
  1. Setup - Install the required packages
make all
  1. Train the model
python model.py
  1. Run the application
python main.py

The dataset is from https://www.kaggle.com/datasets/anandhuh/population-data-china

Containerization

# create image
docker build -t population-predictor:latest .

# create and run container
docker run --rm -p 5000:5000 --name population-predictor-app population-predictor:latest

Now you can access service on http://127.0.0.1:5000/

Set up on GCP

  1. Create a new project and check if the project correct and set working project if not. In this step you need to record the , which will be used in next steps:

    gcloud projects describe $GOOGLE_CLOUD_PROJECT
    
    gcloud config set project $GOOGLE_CLOUD_PROJECT 
    
  2. Paste command below on the GCP shell:

git clone [email protected]:xzhnshng/IDS721-group-project.git
  1. In the project folder, build the containerized flask application image:

    gcloud builds submit --tag gcr.io/<PROJECT-ID>/app 
    
  2. Last step, deploy the image on the cloud run service:

gcloud run deploy --image gcr.io/<PROJECT-ID>/app --platform managed

And you will need to name your service and select region you want to deploy. Screen Shot 2022-04-12 at 2 23 05 PM

Lastly, you can see the service running on the given URL:

WechatIMG91

Load Testing

I used https://locust.io/ to start load testing for the flask project.

  1. Download locust

    pip3 install locust
    
  2. Write locustfile.py:

    import time
    from locust import HttpUser, task, between
    
    class QuickstartUser(HttpUser):
    
        @task
        def submitForm(self):
            self.client.post("/predict", {"Year":"2024"})
    
  3. Run "locust". Once you’ve started Locust, open up a browser and point it to http://localhost:8089. You will be greeted with something like this:

Screen Shot 2022-04-12 at 10 03 08 PM

  1. Here is our test result. Screen Shot 2022-04-12 at 5 35 13 PM

ids721-group-project's People

Contributors

qishenwang avatar xzhnshng avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.