You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dsa-solutions/gfg-solutions/0025-K-Nearest Neighbor.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
id: K-Nearest-Neighbor
3
3
title: K-Nearest Neighbor (Geeks for Geeks)
4
-
sidebar_label: Problems - K-Nearest Neighbor
4
+
sidebar_label: 0025 K-Nearest Neighbor
5
5
tags:
6
6
- Intermediate
7
7
- Machine Learning
@@ -19,7 +19,7 @@ KNN is one of the most basic yet essential classification algorithms in machine
19
19
20
20
It is widely disposable in real-life scenarios since it is non-parametric, meaning it does not make any underlying assumptions about the distribution of data (as opposed to other algorithms such as GMM, which assume a Gaussian distribution of the given data). We are given some prior data (also called training data), which classifies coordinates into groups identified by an attribute.
21
21
22
-

22
+

23
23
24
24
## Intuition Behind KNN Algorithm
25
25
@@ -37,7 +37,7 @@ The value of K is critical in the K-NN algorithm. A small K can make the model s
37
37
K-Nearest Neighbor (K-NN) is a simple, supervised machine learning algorithm used for classification and regression tasks. It works by finding the K closest data points (neighbors) to the query point and using them to make predictions. For classification, it assigns the class most common among the neighbors. For regression, it averages the values of the neighbors.
Implement the function `knn()` that takes in a dataset, a query point, and an integer k. The function should return the k points in the dataset that are closest to the query point based on Euclidean distance.
68
+
Implement the function $knn()$ that takes in a dataset, a query point, and an integer k. The function should return the k points in the dataset that are closest to the query point based on Euclidean distance.
69
69
70
70
Expected Time Complexity: $O(n log n)$ for sorting the dataset.
0 commit comments