0% found this document useful (0 votes)
50 views2 pages

KNN Price Prediction for Homes

A real estate agency aims to predict house prices using the K-Nearest Neighbors (KNN) algorithm based on house size and number of bedrooms. They analyzed a dataset of recent sales and applied KNN with k=3 to estimate the price of an 1800 sq ft house with 3 bedrooms, resulting in a predicted price of $350,000. The method utilizes the prices of the three nearest neighbors to make this estimation.

Uploaded by

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

KNN Price Prediction for Homes

A real estate agency aims to predict house prices using the K-Nearest Neighbors (KNN) algorithm based on house size and number of bedrooms. They analyzed a dataset of recent sales and applied KNN with k=3 to estimate the price of an 1800 sq ft house with 3 bedrooms, resulting in a predicted price of $350,000. The method utilizes the prices of the three nearest neighbors to make this estimation.

Uploaded by

anusreev22
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

A real estate agency wants to develop a system that helps predict house prices based on the

size of the house and the number of bedrooms. They have collected a small dataset of recent
sales and want to apply the K-Nearest Neighbors (KNN) algorithm to estimate prices for new
homes. The dataset includes house size, number of bedrooms, and the house price.

House Size (sq ft) Bedrooms Price ($1000s)

1500 3 300

1700 3 350

2000 4 400

2100 4 410

2500 4 450

Question:

Predict the price of a house that is 1800 sq ft with 3 bedrooms using the
KNN algorithm with k=3.

Solution:

Step 1: Understand the Data

The dataset contains two features:

 House Size (Input Feature 1)


 Bedrooms (Input Feature 2)

The target is the House Price.

Step 2: Choose the KNN Parameters

 Number of neighbors k=3


Step 3: Calculate the Distance

Step 4: Calculate Distances


Step 5: Identify Neighbors

Select the 3 nearest neighbors based on the smallest distances:

 House 2 (d = 100)
 House 3 (d ≈ 200.002)
 House 1 (d = 300)

Step 6: Predict the Price

Conclusion:

The predicted price for the new house (1800 sq ft, 3 bedrooms) using KNN with k=3 is
$350,000. KNN effectively uses the nearest neighbor's known prices to estimate the pricing
for an unseen house by leveraging both house size and number of bedrooms.

You might also like