Skip to content

NavidBinAhmed/webapp_boston-house-pricing

Repository files navigation

End-to-End Boston House Pricing Prediction using Machine Learning Regression Model and RESTful API

Following 13 parameters related to city-dwelling, the model predicts the prices for new house based on the user preferences.

Tools and Software Requirement

Tools used:

Tools

Cloud and software used:

  1. Render Account
  2. VS Code IDE

Dataset Information

Dataset Characteristics:

:Number of Instances: 506 

:Number of Attributes: 13 numeric/categorical predictive. Median Value (attribute 14) is usually the target.

:Attribute Information (in order):
    - CRIM     per capita crime rate by town
    - ZN       proportion of residential land zoned for lots over 25,000 sq.ft.
    - INDUS    proportion of non-retail business acres per town
    - CHAS     Charles River dummy variable (= 1 if tract bounds river; 0 otherwise)
    - NOX      nitric oxides concentration (parts per 10 million)
    - RM       average number of rooms per dwelling
    - AGE      proportion of owner-occupied units built prior to 1940
    - DIS      weighted distances to five Boston employment centres
    - RAD      index of accessibility to radial highways
    - TAX      full-value property-tax rate per $10,000
    - PTRATIO  pupil-teacher ratio by town
    - B        1000(Bk - 0.63)^2 where Bk is the proportion of black people by town
    - LSTAT    % lower status of the population
    - MEDV     Median value of owner-occupied homes in $1000's

:Missing Attribute Values: None

Observations & Prediction

Observations

  1. Pirplot pairplot

Visualizing relationship between each pair of features.

CRIM_Price

It is observed that, with lower crime rate, the price increases

RM_Price

With increaing number of rooms in the apartment indicates higher rent.

RM_Price_Corr

A linear correlation is observed between the Price (dependant) and Room Numbers (independent) features.

LSTAT_Price

When the LSTAT is decreasing, the price is increasing. Features are found to be negatively corralated.

CHAS_Price

These features are not at all correlated.

There should have some relationships of linearity, either positively or negatively.

  1. PTRATIO_Price

Some negative corralation exist with inverse relationship. While PTRATIO increases price decreases.

Prediction

pred_model

Prediction model is linear, so the model expects to perform well (y_test vs prediction)

residuals

Normally distributed, and there is little error between 10 to 30 (right side)

pred and res

Scatter plot with respect to prediction and residulas. Uniform distribution.

Model expects to work well, and to make it guaranteed, let's have a look at the:

Performance Metrics

  • MAE: 3.162709871457406

  • MSE: 21.517444231177212

  • RMSE: 4.638689926172821

  • R-Squared: 0.7112260057484932

  • Adjusted R-Squared: 0.6840226584639308

    Here, Adjusted R-Squared is less than R-Squared. Which is expected and looks good.

New data prediction : Deployed App Testing

prediction_webapp

App Interface

prediction_results

Predicts the price.

Deployed App Link: Webapp Link

.......................................................................................................................................................................................

Procedure (common for any projects)

ML and Webapp

  • Create a new environment
  • conda create -p means the venv environment is created within the specified folder location
conda create -p venv python==3.11 -y 
  • Activate the environment
conda activate venv/
  • for python (vs code terminal, specifically for webapp development)
python3 -m venv evn_name
source evn_name/bin/activate
  • Installing the requirements
pip install -r requirements.txt
  • Git Configuaration between VS Code and GitHub account
git config --global user.name
git config --global user.email
  • Commiting files
git status
git add . 
git commit -m "commit includes the files"
git push origin main

Deployment on Render

  1. Picked Webservices

  2. Selected 'Git Public Repository' (for privet repository, sign-in to GitHub under 'Git Provider' is required)

  3. Next, picked a Name as URL, and Python 3 as *Language

  4. Branch is main and Region is Oregon as default

  5. Keep Root Directory as it is, it will redirect from GitHub

  6. Build Command

pip install -r requirements.txt
  1. Start Command ( gunicorn app_name_used_as_.py_file:app )
gunicorn flask_app:app
  1. Select Subscription Plan, Free in my case
  2. Click Deploy Web Service

Error Handling

  1. The deploy was failing with an error message:
    Getting requirements to build wheel: finished with status 'error'
    error: subprocess-exited-with-error
    
  • Added 'wheel' and modified 'scikit-learn' instead of 'sklearn' in the requirements.txt file
  1. The flask_app.py file was having error with importing 'numpy' package
  • Switched to the environment activated for the project instead of the default/ old environment. This error occured as environemnt where the VS Code was running on was unable to access the packages installed.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages