0% found this document useful (0 votes)
25 views7 pages

House Price Prediction Analysis Project

Uploaded by

safiulfulu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views7 pages

House Price Prediction Analysis Project

Uploaded by

safiulfulu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

house-price-prediction-analysis

September 2, 2024

1 House Price Prediction Analysis

[1]: import pandas as pd

[7]: # Load the dataset


df = pd.read_csv('https://raw.githubusercontent.com/ywchiu/riii/master/data/
house-prices.csv')

[8]: df

[8]: Home Price SqFt Bedrooms Bathrooms Offers Brick Neighborhood


0 1 114300 1790 2 2 2 No East
1 2 114200 2030 4 2 3 No East
2 3 114800 1740 3 2 1 No East
3 4 94700 1980 3 2 3 No East
4 5 119800 2130 3 3 3 No East
.. … … … … … … … …
123 124 119700 1900 3 3 3 Yes East
124 125 147900 2160 4 3 3 Yes East
125 126 113500 2070 2 2 2 No North
126 127 149900 2020 3 3 1 No West
127 128 124600 2250 3 3 4 No North

[128 rows x 8 columns]

[9]: # Display the f i r s t few rows o f the dataset


df.head()

[9]: Home Price SqFt Bedrooms Bathrooms Offers Brick Neighborhood


0 1 114300 1790 2 2 2 No East
1 2 114200 2030 4 2 3 No East
2 3 114800 1740 3 2 1 No East
3 4 94700 1980 3 2 3 No East
4 5 119800 2130 3 3 3 No East

2
2 Data Cleaning

[10]: # Check f o r missing values


df.isnull().sum()

[10]: Home 0
Price 0
SqFt 0
Bedrooms 0
Bathrooms 0
Offers 0
Brick 0
Neighborhood 0
dtype: int64

3 Exploratory Data Analysis

[14]: import numpy as np


import matplotlib.pyplot as p l t
import seaborn as sns

[15]: # Overview o f the dataset


df.describe()

[15]: Home Price SqFt Bedrooms Bathrooms \


count 128.000000 128.000000 128.000000 128.000000 128.000000
mean 64.500000 130427.343750 2000.937500 3.023438 2.445312
std 37.094474 26868.770371 211.572431 0.725951 0.514492
min 1.000000 69100.000000 1450.000000 2.000000 2.000000
25% 32.750000 111325.000000 1880.000000 3.000000 2.000000
50% 64.500000 125950.000000 2000.000000 3.000000 2.000000
75% 96.250000 148250.000000 2140.000000 3.000000 3.000000
max 128.000000 211200.000000 2590.000000 5.000000 4.000000

Offers
count 128.000000
mean 2.578125
std 1.069324
min 1.000000
25% 2.000000
50% 3.000000
75% 3.000000
max 6.000000

[16]: # Distribut io n o f house p r i c e s


plt.figure(figsize=(8, 6))

3
sns.histplot(df['Price'], bins=50, kde=True)
plt.title('Distribution of House Prices')
plt.xlabel('Price')
plt.ylabel('Frequency')
plt.show()

[17]: # Relationship between house s i z e and price


plt.figure(figsize=(10, 6))
sns.scatterplot(x='SqFt', y='Price', data=df)
plt.title('House Size vs. Price')
plt.xlabel('Size (SqFt)')
plt.ylabel('Price')
plt.show()

4
[18]: # Average house price f o r number o f bedrooms
plt.figure(figsize=(8, 6))
sns.barplot(x='Bedrooms', y='Price', data=df, palette='coolwarm')
plt.title('Average House Price by Number of Bedrooms')
plt.xlabel('Number of Bedrooms')
plt.ylabel('Average Price')
plt.show()

C:\Users\SOUMEN\AppData\Local\Temp\ipykernel_19820\3439380094.py:3:
FutureWarning:

Passing `palette` without assigning `hue` is deprecated and will be removed in


v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same
effect.

sns.barplot(x='Bedrooms', y='Price', data=df, palette='coolwarm')

5
[23]: # Average house price per Neighborhood
plt.figure(figsize=(12, 6))
sns.boxplot(x='Neighborhood', y='Price', data=df)
plt.xticks(rotation=45)
plt.title('House Prices by Neighborhood')
plt.show()

6
Insights from the Analysis:
From this project, we can conclude the following insights-
• Size and Price: House size is one of the key factors driving house prices. Larger
homes generally command higher prices.
• Bedrooms and Price: The number of bedrooms also impacts house prices, but the
relationship is not linear—other factors like location and size play important roles.
• Location's Influence: Location is a critical factor in determining house prices, with
significant variation across different regions or neighborhoods.

You might also like