ScratchData LogoScratchData
Back to sureornot's profile

KNN

SUsureornot•Created September 1, 2022
KNN
10
6
150 views
View on Scratch

Instructions

K-nearest neighbors (KNN) is a type of supervised learning algorithm used for both regression and classification. Slider to set the K and then click the green flag. Please run this project at: https://turbowarp.org/727082120 The KNN Algorithm: 1. Load the data 2. Initialize K to your chosen number of neighbors 3. For each example in the data 3.1 Calculate the distance between the query example and the current example from the data. 3.2 Add the distance and the index of the example to an ordered collection 4. Sort the ordered collection of distances and indices from smallest to largest (in ascending order) by the distances 5. Pick the first K entries from the sorted collection 6. Get the labels of the selected K entries 7. If regression, return the mean of the K labels 8. If classification, return the mode of the K labels

Description

Project Reference: https://scratch.mit.edu/projects/375033920/ Thank you piano_miles. https://medium.com/swlh/k-nearest-neighbor- ca2593d7a3c4 https://www.javatpoint.com/k-nearest-neighbor-algorithm-for-machine-learning Sorting: Binary Sort from Zro716's project - https://scratch.mit.edu/projects/26497383/ Thank you Zro716.

Project Details

Project ID727082120
CreatedSeptember 1, 2022
Last ModifiedNovember 8, 2022
SharedNovember 8, 2022
Visibilityvisible
CommentsAllowed