0% found this document useful (0 votes)
47 views

KNN Solved Numerical Problem( Regression)

The document outlines a KNN regression problem to predict monthly sales revenue for a new retail store based on its size and number of employees. Using a training dataset, the Euclidean distances to existing stores are calculated, and the three closest neighbors are selected to estimate the revenue. The predicted monthly sales revenue for the new store is approximately $83,333.33.

Uploaded by

Shaharyar Asif
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)
47 views

KNN Solved Numerical Problem( Regression)

The document outlines a KNN regression problem to predict monthly sales revenue for a new retail store based on its size and number of employees. Using a training dataset, the Euclidean distances to existing stores are calculated, and the three closest neighbors are selected to estimate the revenue. The predicted monthly sales revenue for the new store is approximately $83,333.33.

Uploaded by

Shaharyar Asif
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
You are on page 1/ 3

KNN Solved Numerical

Problem(Regression)
You are a business analyst at a retail company and want to predict the monthly sales revenue
of new stores based on their size (in square feet) and the number of employees.

Dataset:

Suppose you have the following training dataset:

Store Size (sq ft) Number of Employees Monthly Sales Revenue ($)

1500 5 30000

2000 7 50000

2500 10 70000

3000 15 80000

3500 20 100000

Goal:

Predict the monthly sales revenue for a new store with a size of 2800 sq ft and 12 employees.

Step 1: Data Preparation

Prepare your data using the two features (store size and number of employees) to find the K
nearest neighbors for the new store.

Step 2: Choosing K

Choose k = 3. This means you will consider the 3 closest neighbors to make your prediction.

Step 3: Distance Calculation

Calculate the Euclidean distance between the new store and each store in the dataset using the
formula:

Distance = sqrt((X1 - X2)² + (Y1 - Y2)²)

Where:

 X1 and Y1 are the features of the new store (size and employees).
 X2 and Y2 are the features of each training store.
Calculate Distances:

 For Store 1 (1500 sq ft, 5 employees): Distance = sqrt((1500 - 2800)² + (5 - 12)²)


Distance = sqrt((1300)² + (-7)²)
Distance = sqrt(1690000 + 49)
Distance ≈ 1300.02
 For Store 2 (2000 sq ft, 7 employees): Distance = sqrt((2000 - 2800)² + (7 - 12)²)
Distance = sqrt((800)² + (-5)²)
Distance = sqrt(640000 + 25)
Distance ≈ 800.02
 For Store 3 (2500 sq ft, 10 employees): Distance = sqrt((2500 - 2800)² + (10 - 12)²)
Distance = sqrt((-300)² + (-2)²)
Distance = sqrt(90000 + 4)
Distance ≈ 300.01
 For Store 4 (3000 sq ft, 15 employees): Distance = sqrt((3000 - 2800)² + (15 - 12)²)
Distance = sqrt((200)² + (3)²)
Distance = sqrt(40000 + 9)
Distance ≈ 200.02
 For Store 5 (3500 sq ft, 20 employees): Distance = sqrt((3500 - 2800)² + (20 - 12)²)
Distance = sqrt((700)² + (8)²)
Distance = sqrt(490000 + 64)
Distance ≈ 700.04

Step 4: Finding Neighbors

Now, we have calculated the distances for each store. Here are the distances we obtained:

 Store 1: 1300.02
 Store 2: 800.02
 Store 3: 300.01
 Store 4: 200.02
 Store 5: 700.04

Now, we will select the three closest neighbors (smallest distances):

1. Store 4 (200.02)
2. Store 3 (300.01)
3. Store 5 (700.04)

Step 5: Target Value Prediction

Next, we will take the monthly sales revenues of these three nearest neighbors and calculate
their average.

 Store 4 Revenue: $80,000


 Store 3 Revenue: $70,000
 Store 5 Revenue: $100,000
Average Revenue = (80000 + 70000 + 100000) / 3
Average Revenue = 250000 / 3
Average Revenue ≈ 83333.33

The predicted monthly sales revenue for the new store (2800 sq ft and 12 employees) is
approximately $83,333.33.

You might also like