- KNN:
- 1. Load the training and test data
- 2. Choose the value of K
- 3. For each point in test data:
- - find the Euclidean distance to all training data points
- - store the Euclidean distances in a list and sort it
- - choose the first k points
- - assign a class to the test point based on the majority of classes present in the chosen points
- 4. End
- Decision Tree:
- 1. Place the best attribute of the dataset at the root of the tree.
- 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.
- 3. Repeat step 1 and step 2 on each subset until you find leaf nodes in all the branches of the tree.
- K-Means Clustering Algorithm:
- Input: Data points D, Number of clusters k
- Step 1: Initialize k centroids randomly
- Step 2: Associate each data point in D with the nearest centroid. This will divide the data points
- into k clusters.
- Step 3: Recaculate the position of centroids.
- Repeat steps 2 and 3 until there are no more changes in the membership of the data points.
- Output: Data points with cluster memberships
Recent Pastes