0% found this document useful (0 votes)
14 views2 pages

Decision Tree and KNN Tutorial Questions

Uploaded by

Md Shafaque
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Decision Tree and KNN Tutorial Questions

Uploaded by

Md Shafaque
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Tutorial Questions

1. You have a friend who only does one of four things on every Saturday afternoon: go shopping,
watch a movie, play tennis, or just stay in. You have observed your friend’s behavior over 11
different weekends. On each of these weekends you have noted the weather (sunny, windy, or
rainy), whether her parents visit (visit or no-visit), whether she has drawn cash from an ATM
machine (rich or poor), and whether she had an exam during the coming week (exam or no-exam).
You have built the following data table:

You now want to build a decision tree to predict the activity of your friend on any future Saturday
afternoon from the observed values of Weather, Parents, Cash, and Exam.

i. Suppose that you want to build a very simple decision tree that allows you to predict the value of
Decision from a single observable attribute (Weather, Parents, Cash, or Exam). What would be this
attribute? If there is a tie among several attributes give each of them. For each attribute that you
have selected for each value of this attribute, give the answer that the decision tree would give
using the majority rule, as well as the number of misclassified examples.
ii. Draw the full tree that correctly classifies all the examples.

2. Consider dataset

Find the class of the new dataset given below using KNN algorithm, K=5.
3. Cluster the following eight points (with (x, y) representing locations) into three clusters:
A1(2, 10), A2(2, 5), A3(8, 4), A4(5, 8), A5(7, 5), A6(6, 4), A7(1, 2), A8(4, 9)

Initial cluster centers are: A1(2, 10), A4(5, 8) and A7(1, 2).

4.

Common questions

Powered by AI

Drawing a full decision tree involves several steps: Firstly, start by selecting the attribute with the highest information gain or lowest Gini index as the root node. Split the dataset based on the chosen attribute. For each subset of the data, repeat the process by selecting attributes that offer the highest information gain. Continue splitting the data until each leaf node contains only one class or no significant information gain is possible. Every node in the tree represents a decision point based on attribute values, while leaf nodes show the class label predicted by the tree. The process ensures no misclassified examples remain, meaning every example from the dataset is correctly classified .

To cluster points initially into three clusters, one can use the K-Means clustering algorithm. This involves the following procedure: First, choose three initial cluster centers, which can be predetermined or selected randomly from the dataset. Then, calculate the distance of each point to each cluster center and assign each point to the nearest cluster. Following this, recompute the centroids of clusters by taking the mean of all points assigned to each cluster. Continue reassigning points based on updated centroids until the cluster assignments no longer change, or a predetermined number of iterations is reached .

When applying the KNN algorithm, selecting an appropriate distance metric is crucial. Factors to consider include the nature of the data, as Euclidean distance works well for continuous numerical data, while Manhattan distance might be more appropriate for grid-like paths. If the dataset contains categorical variables, employing the Hamming distance can be beneficial. The scale of features is also vital, thus data normalization is often necessary to ensure each feature contributes equally to the distance metric. Considering these factors ensures that the chosen distance metric effectively captures the inherent relationships in the dataset .

To determine the most significant attribute for constructing a simple decision tree, you need to analyze each attribute's capacity to reduce uncertainty or entropy in predicting the outcome. This is often done by calculating the information gain or Gini index for each attribute. In the given scenario, observe the data and calculate for each of the attributes (Weather, Parents, Cash, Exam). The attribute with the highest information gain is chosen as the root. The decision tree will predict an activity based on the majority rule for each attribute's value. For instance, if 'Weather' is chosen and the weather is 'sunny', it will predict the activity that most frequently occurred in that weather condition. Misclassification examples are those predicted incorrectly based on this majority rule .

The primary challenges of classifying a dataset using KNN with a high value of 'k' include the risk of oversmoothing the boundary between classes, leading to underfitting where the model may not capture the class distinctions present in the data. Additionally, computational complexity increases as 'k' becomes larger, necessitating more distance calculations. Furthermore, high 'k' values make the model more susceptible to the influence of outliers, potentially biasing the class decision towards the most prevalent class in the dataset. Proper standardization and normalization of features can mitigate some balance issues .

Different weather conditions impact classification predictions in the decision tree by affecting which activity becomes the most likely choice. For instance, if 'weather' is the selected root attribute due to a high information gain, 'sunny' weather could correlate with 'playing tennis' as the most predicted activity. In contrast, 'rainy' weather might suggest 'watching a movie' or 'staying in' as predominant activities. The decision tree utilizes these correlations to make predictions, though misclassification could occur if weather does not strongly dictate her choices, highlighting the importance of comprehensive data .

The K-Nearest Neighbors (KNN) algorithm classifies a new data point by identifying 'k' nearest data points from the dataset based on a defined distance metric, commonly Euclidean distance. For the new data point, the algorithm counts the number of instances of each class among these nearest neighbors. The class with the highest frequency is assigned to the new data point. Important considerations when choosing 'k' include: A small 'k' can make the algorithm sensitive to noise, while a large 'k' can smooth out local patterns causing underfitting. It is crucial to experiment with different 'k' values to find a balance that accurately models the dataset .

Misclassified examples in decision trees indicate weaknesses in decision rule formulation, where the chosen attribute does not perfectly discriminate among different classes. They affect decision rules by indicating areas where the decision tree's model may have overfitted specific aspects of the training data or failed to capture important relationships. Strategies to reduce misclassifications include pruning the tree post-construction to remove branches that add complexity without improving classification accuracy, using more sophisticated splitting criteria that maximize information gain, and potentially employing ensemble methods like random forests that combine multiple decision trees to improve accuracy and robustness .

Initial selection of cluster centers significantly influences the final clustering outcome in K-Means. Poor initial center choice can lead to suboptimal solutions where clusters do not accurately reflect the inherent structure of the data. For example, if initial centers are chosen too closely or are outliers, it can result in empty clusters or slow convergence. To mitigate these effects, multiple initializations or advanced methods like K-Means++ can be used to select meaningful initial centers that enhance the chances of converging to a global or near-global minimum .

In decision tree classification, the majority rule is used to predict the class based on the most frequent class of the training samples reaching a leaf node. This rule simplifies decision-making and is intuitive, especially when datasets have balanced class representations. However, majority rule has limitations, especially in unbalanced datasets where it might bias predictions towards the more common class, leading to potential inaccuracies. It does not account for the certainty of the prediction or the distribution of the other classes, limiting its effectiveness in highly diverse or uncertain scenarios .

You might also like