Oscail naisc i dtáb nua
    • Tuairisc Oibre
    • Ríomhphost
    • Athscríobh
    • Caint
    • Gineadóir Teidil
    • Freagra Cliste
    • Dán
    • Aiste
    • Scéal grinn
    • Postáil Instagram
    • Postáil X
    • Postáil Facebook
    • Scéal
    • Litir chlúdaigh
    • Atosaigh
    • Tuairisc den Jab
    • Litir Mholta
    • Litir éirí as
    • Litir Chuireadh
    • Teachtaireacht bheannaithe
    • Bain triail as tuilleadh teimpléad
  1. The K-Nearest Neighbors (KNN) algorithm is a supervised, non-parametric, instance-based learning method used for both classification and regression tasks. It predicts the output for a new data point by looking at the ‘k’ closest points in the training dataset and using majority voting (classification) or averaging (regression) to decide the result.

    KNN is called a lazy learner because it doesn’t build a model during training — it simply stores the dataset and performs computations at prediction time.

    How it works:

    1. Choose k – the number of neighbors to consider.

    2. Calculate distances – commonly Euclidean, Manhattan, or Minkowski distance metrics.

    3. Find nearest neighbors – select the k points with the smallest distances.

    4. Predict – Classification: Assign the class most common among neighbors. Regression: Take the average of neighbors’ values.

    Example Python Implementation (from scratch):

    Aiseolas
    Go raibh maith agat!Inis tuilleadh dúinn
  2. A Step-by-Step Guide to K-Nearest Neighbors (KNN) in Machine Learning

    2 days ago · Let's get started! What is KNN? K-Nearest Neighbors (KNN) is a straightforward powerful supervised machine learning algorithm used for both classification and regression tasks. Its …

  3. K-Nearest Neighbor (KNN) Algorithm - GeeksforGeeks

    12 Márta 2026 · In the k-Nearest Neighbours algorithm k is just a number that tells the algorithm how many nearby points or neighbors to look at when it makes a …

  4. KNN Algorithm – K-Nearest Neighbors Classifiers and Model Example

    Learn how the K-Nearest Neighbors (K-NN) algorithm works with practical examples. See how to calculate the distance between a new data entry and existing data using the Eucl…

    The K-NN algorithm compares a new data entry to the values in a given data set (with different classes or categories). Based on its closeness or similarities in a given range (K) of neighbors, the algorithm assigns the new data to a class or category in the data …
    Féach tuilleadh ar freecodecamp.org
  5. Python Machine Learning - K-nearest neighbors (KNN)

    By choosing K, the user can select the number of nearby observations to use in the algorithm. Here, we will show you how to implement the KNN algorithm for …

    Sampla de chód

    knn = KNeighborsClassifier(n_neighbors=5)
    knn.fit(data, classes)
    prediction = knn.predict(new_point)
    plt.scatter(x + [new_x], y + [new_y], c=classes + [prediction[0]])
    plt.text(x=new_x-1.7, y=new_y-0.7, s=f"new point, class: {prediction[0]}")...
  6. K-Nearest Neighbors (KNN) in Machine Learning

    Learn how to use KNN algorithm for classification and regression problems with examples and Python code. KNN algorithm finds the k-nearest neighbors of a …

    Ar iarraidh:
    • Example
    Ní mór go mbeadh sé seo san áireamh:
  7. K-Nearest Neighbors (KNN): A Beginner-Friendly Guide …

    4 Feabh 2025 · The K in KNN represents the number of nearest neighbors we consider for making predictions. Example: If K=3, the algorithm looks at the 3 …

  8. Iarrann daoine freisin
    Loading
    Unable to load answer
  9. KNN_tutorial.ipynb - Colab

    In this tutorial, we'll use the KNN algorithm to predict median house prices of districts in California, as well as apply the algorithm to a condensed matter physics problem.

  10. KNN in Machine Learning Explained (with Python …

    29 DFómh 2025 · Learn K-Nearest Neighbors (KNN) algorithm in machine learning with detailed Python examples. Understand distance metrics...

  11. K Nearest Neighbor Algorithm (KNN) Explained – …

    30 DFómh 2025 · K nearest neighbor algorithm (KNN) explained with examples, formulas, and Python code. Learn what is the KNN algorithm, how it works, and …

  12. The k-Nearest Neighbors (kNN) Algorithm in Python

    In this tutorial, you'll learn all about the k-Nearest Neighbors (kNN) algorithm in Python, including how to implement kNN from scratch, kNN hyperparameter …