KNN Solved Numerical Problem( Regression)
KNN Solved Numerical Problem( Regression)
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:
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.
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.
Calculate the Euclidean distance between the new store and each store in the dataset using the
formula:
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:
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
1. Store 4 (200.02)
2. Store 3 (300.01)
3. Store 5 (700.04)
Next, we will take the monthly sales revenues of these three nearest neighbors and calculate
their average.
The predicted monthly sales revenue for the new store (2800 sq ft and 12 employees) is
approximately $83,333.33.