# K Nearest Neighbor Regression Algorithm Explain with Project

**In this ML Algorithms course tutorial, we are going to learn “** K Nearest Neighbor Regression **in detail. we covered it by practically and theoretical intuition.**

**What is**K Nearest Neighbor**?**- What does the K stand for in K nearest neighbors?
**What is**K Nearest Neighbor**used for?****How do**K Nearest Neighbor**work?****What is**K Nearest Neighbor Regression**?****What is Euclidian Distance Manhattan Distance?**- What is nearest Neighbour rule?
**What is**K Nearest Neighbor Regression**diagram?****How to implement**K Nearest Neighbor Regression**in python using sklearn?**

## K Nearest Neighbor Regression Project

""" ## Business Problem - Predict the Price of Bangalore House **Using** K Nearest Neighbor Regression - Supervised Machine Learning Algorithm ### Load Libraries """ import pandas as pd """### Load Data""" path = r"https://drive.google.com/uc?export=download&id=1xxDtrZKfuWQfl-6KA9XEd_eatitNPnkB" df = pd.read_csv(path) df.head() """## Split Data""" X = df.drop('price', axis=1) y = df['price'] print('Shape of X = ', X.shape) print('Shape of y = ', y.shape) from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=51) print('Shape of X_train = ', X_train.shape) print('Shape of y_train = ', y_train.shape) print('Shape of X_test = ', X_test.shape) print('Shape of y_test = ', y_test.shape) """##K Nearest Neighbor Regression - ML Model Training""" from sklearn.neighbors import KNeighborsRegressor regressor = KNeighborsRegressor(n_neighbors=5) regressor.fit(X_train, y_train) regressor.score(X_test, y_test) """## Predict the value of Home""" X_test.iloc[-1, :] regressor.predict([X_test.iloc[-1, :]]) y_test.iloc[-1] y_pred = regressor.predict(X_test) y_pred y_test