**MISSION 139**

# Introduction To K-Nearest Neighbors

In this lesson of the machine learning fundamentals course, we'll learn about k-nearest neighbors, which is a useful machine learning technique. __Machine learning__ is a process of discovering patterns in existing data to make predictions.

To learn how k-nearest neighbors works, we will explore AirBnB data to find optimal rental pricing â€” low enough to be competitive, but not so low that we miss out on potential revenue.

In the real world, you would likely use `scikit-learn` to implement the k-nearest neighbors algorithm. But understanding how this algorithm works â€śunder the hoodâ€ť will help you understand when to apply it, so in this mission we will implement the algorithm by hand.

As we work through the AirBnB pricing question, we will walk through the entire machine learning workflow â€” from selecting a feature to testing the model â€” so you can see what itâ€™s like to explore a problem like a data scientist would.

As with all our courses, you will be asked to apply what youâ€™re learning in our in-browser app, which will also check your answers so you can ensure you've fully mastered each concept.

#### Objectives

#### Mission Outline

1. Problem definition

2. Introduction to the data

3. K-nearest neighbors

4. Euclidean distance

5. Calculate distance for all observations

6. Randomizing, and sorting

7. Average price

8. Function to make predictions

9. Next steps

10. Takeaways