2020 answer v2 by sallam
2020 answer v2 by sallam
2020 answer v2 by sallam
0)
By Dr\ Hanaa Bayoumi
Solved by Ahmed Sallam if you find any mistakes, please contact me.
ال تنسونا من صالح دعائكم
Question 1:
You will find Mistakes in red.
وlogistic regression ودول بيمثلوdecision boundaries of classifiers لplot بيقولك معاك كذا
عملهاmodel الي الdata و كام عدد الalgorithm اسم الplot اكتب جمب كلDecision tree وKNN
wrong classification
Decision tree
Logistic regression
Number of mistakes = 2
Number of mistakes = 6
KNN
No Mistake
Question 2: CNN is out of course scope.
Question 3: in SVM show how to express the margin in terms of weight (W)
Weight (W) بالنسبه لmargin لproof ببساطه اكتب ال
• The margin is the distance between the decision boundary (hyperplane) and the nearest data point
from either class. The margin is typically expressed in terms of the weight vector (W) and bias term
(b) of the hyperplane.
• Hyperplane = W • X + b = 0
- Logistic regression: logistic regression has linear decision boundaries, so it may not be able to
correctly separate the training data because the data is not linearly separable.
- SVM with kernel: it can be a non-linear decision boundary. It can capture more complex
relationships in this data, making it suitable for the classes that are not linearly separable.
- Decision tree: can be model complex decision boundaries by making splits along different features.
They can accommodate non-linear relationships in the data.
- 3-nearest-neighbor classifier: may not be able to correctly separate this training data because it relies
on the local neighborhood of points. In this case where different classes are mixed closely, it might
make errors in classification.
5) Describe the difference between parametric methods and nonparametric methods.
Parametric methods make assumptions about the functional form of the underlying data distribution
and have a fixed number of parameters, while nonparametric methods do not make explicit
assumptions about the distribution and can adapt to more complex patterns without a predetermined
number of parameters.
6) What is the similarity and difference between feature selection and dimensionality reduction?
Feature selection involves choosing a subset of relevant features from the original feature set, while
dimensionality reduction aims to transform the data into a lower-dimensional space, preserving
essential information by combining or projecting the original features.
It is not well separated because some points in each cluster are closer to points in another cluster than
to points in the same cluster.
Notic:
Parametric model:
- Model fit the data exactly
- this models have a parameters that model are try to find and calculate them exactly
Like Linear Regression W.X+b=0
Non- Parametric model:
- The data tell you what the fit method look like.
- they have a parameters but we don’t know how many of them, the data will tell the model how many
of them.
10) Most machine learning approaches use training sets, test sets and validation sets to derive
models. Describe the role each of the three sets plays!
اشرحهم بالطريقه االحسن ليك والي انت فاهمها-
Training Set: is used to train the machine learning model. It consists of a labeled dataset where the
algorithm learns the patterns, relationships, and features present in the data. The model adjusts its
parameters during training to minimize the difference between its predictions and the actual labels in
the training set.
Validation Set: is used to fine-tune the hyperparameters of the model and to assess its performance
during training. The model is not directly trained on the validation set, but its performance on this set
helps in selecting the best model architecture, tuning parameters, and preventing overfitting. It
provides an unbiased evaluation before testing on unseen data.
Test Set: is a completely independent dataset that the model has not seen during training or validation.
It is used to evaluate the final performance of the trained model. its simulates real-world scenarios
where the model encounters new, unseen data. Evaluating on it provides an unbiased estimate of the
model's generalization performance and helps assess its ability to make accurate predictions on new,
unseen examples.
A B C D
Solution: A 0 1 4 5
B 0 2 6
First, we choose the minimum distance to choose the clusters (A, B) = 1.
C 0 3
Distance between Cluster (A, B) and C = Max (AC, BC) = (4, 2) = 4 D 0
Distance between Cluster (A, B) and D = Max (AD, BD) = (5, 6) = 6 (A, B) C D
(A, B) 0 4 6
C 0 3
D 0
Second, we choose the minimum distance to choose the new clusters (C, D) = 3
Distance between Cluster (C, D) and (A, B) = Max (C, (A, B), D, (A, B)) = (4, 6) = 6
Question 6:
You are a robot in an animal shelter, and must learn to
discriminate Dogs from Cats. You choose to learn a
Naive Bayes classifier. You are given the following
examples:
a) Construct a classifier using Naive byes to
discriminate Dogs from Cats.
4 4
P(Cat) = P(Dog) =
8 8
Color Dog Cat
Sound Dog Cat Fur Dog Cat
2 2
1 3 3 1 Brown
Meow Coarse 4 4
4 4 4 4
2 2
3 1 1 3 Black
Bark Fine 4 4
4 4 4 4
Done