TEXT 20
AI LAB - Algorithms 2 Guest on 15th April 2022 11:17:46 PM
  1. KNN:
  2. 1. Load the training and test data
  3. 2. Choose the value of K
  4. 3. For each point in test data:
  5.        - find the Euclidean distance to all training data points
  6.        - store the Euclidean distances in a list and sort it
  7.        - choose the first k points
  8.        - assign a class to the test point based on the majority of classes present in the chosen points
  9. 4. End
  10.  
  11. Decision Tree:
  12. 1. Place the best attribute of the dataset at the root of the tree.
  13. 2. Split the training set into subsets. Subsets should be made in such a way that each subset contains data with the same value for an attribute.
  14. 3. Repeat step 1 and step 2 on each subset until you find leaf nodes in all the branches of the tree.
  15.  
  16. K-Means Clustering Algorithm:
  17. Input: Data points D, Number of clusters k
  18. Step 1: Initialize k centroids randomly
  19. Step 2: Associate each data point in D with the nearest centroid. This will divide the data points
  20. into k clusters.
  21. Step 3: Recaculate the position of centroids.
  22. Repeat steps 2 and 3 until there are no more changes in the membership of the data points.
  23. Output: Data points with cluster memberships

Coding Base is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.