anirbanpranto / house-price-endpoint

An inference endpoint to predict US house price.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

House Price Prediction Endpoint

Endpoint Docker Image CI

How to run

Build the docker image

export DOCKER_BUILDKIT=1
docker build --tag house_price_endpoint:latest  -f Dockerfile .

Run the docker image

You can either run it in detached mode,

docker run -d -p 8000:80 house_price_endpoint:latest

or without detached mode,

docker run -p 8000:80 house_price_endpoint:latest

The app should be running at http://localhost:8000/

Endpoints

The app contains a single endpoint,

/predict

Make a request to the endpoint

curl -X POST http://localhost:8000/predict \
-H 'Content-Type: application/json' \
-d '{
    "features":
        {
            "avg_area_income":79545.45857431678,
            "avg_area_house_age":5.682861321615587,
            "avg_area_number_of_rooms":7.009188142792237,
            "avg_area_number_of_bedrooms":4.09,
            "area_population":23086.800502686456,
            "address":"208 Michael Ferry Apt. 674 Laurabury, NE 37010-5101"
        },
        "provider": "payment-api"
    }'

The output should be similar to,

{
  "features": {
    "avg_area_income": 79545.45857431678,
    "avg_area_house_age": 5.682861321615587,
    "avg_area_number_of_rooms": 7.009188142792237,
    "avg_area_number_of_bedrooms": 4.09,
    "area_population": 23086.800502686456,
    "address": "208 Michael Ferry Apt. 674 Laurabury, NE 37010-5101"
  },
  "provider": "payment-api",
  "output": 1244892.8
}

Testing

If you wish to run tests -

pip install -r requirements.txt
pytest

Performance

The endpoint can serve on average 85 requests/second on Intel i5-1135G, If the number of concurrent users are more than 90, the response time deteroriates, as shown by the locust test below.

Locust

About

An inference endpoint to predict US house price.


Languages

Language:Python 92.7%Language:Dockerfile 7.3%