
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

































CS7641 SL01: Decision Trees Mohamed Ameen Amer
In a supervised learning setting, the learning algorithm will be provided with instances and labels as
training data.
signs) and assign it to a label 𝑦 that belongs to a discrete number of labels 𝑌 (e.g. STOP, Speed Limit,
Keep Right, etc.).
experience) and mapping it to a real continuous value (e.g. expected salary).
we’re willing to model.
target concept.
during the training phase. It’s used to determine the algorithm performance on novel data.
A sequence of decision making points (nodes) applied to every instance to assign it to a specific class.
Example: Classifying vehicles into Sedans and Trucks.
CS7641 SL01: Decision Trees Mohamed Ameen Amer
Note that the usefulness of a question depends upon the answers we got to previous questions.
( 2
𝑛
)
), this why we need to design algorithms to
efficiently search the hypothesis space for the best decision tree.
alone classifies the training examples.
Stop
} else {
Iterate over leaves
CS7641 SL01: Decision Trees Mohamed Ameen Amer
of the tree by looking just one move ahead. It compares all available attributes to find which one
classifies the data the best, but it doesn’t look ahead (or behind) at other attributes to see which
combinations of them classify the data the best. This means that while the algorithm will, in most
cases, come up with a good decision tree, a better one may exist.
of attributes increase, it becomes more likely that running ID3 on it will return a suboptimal decision
tree.
is only one observation per attribute value. For each value of the attribute, the training data
agrees unanimously on a classification and the entropy for each attribute value is 0.
→ Not too big tree.
→ We can use cross-validation to prevent overfitting.
→ Use a validation set and stop when the error is low enough.
→ Build the whole tree, the prune it. Pruning means removing sections of the tree that provide
little power in classifying instances.
continuous values.
CS7641 SL01: Decision Trees Mohamed Ameen Amer
assigning high information gain to these variables but producing a decision tree that might not
generalize well.
measures how broadly partitioned an attribute is and how evenly
partitioned those partitions are.
𝑣
log
𝑣
𝑣
→ If we have an attribute with many possible values, each of which occurs few times, the
fraction
|𝑆
𝑣
|
|𝑆|
will have a small value. This will affect the attribute’s chances of being the best
attribute after an iteration of the ID3 algorithm and help to avoid overfitting.
𝑓𝑒𝑎𝑡𝑢𝑟𝑒𝑠
log 𝑛
𝑠𝑎𝑚𝑝𝑙𝑒𝑠
searching through 𝑂(log 𝑛
𝑓𝑒𝑎𝑡𝑢𝑟𝑒𝑠
) to find the feature that offers the largest reduction in entropy.
This has a cost of 𝑂 (
𝑠𝑎𝑚𝑝𝑙𝑒𝑠
𝑓𝑒𝑎𝑡𝑢𝑟𝑒𝑠
log 𝑛
𝑠𝑎𝑚𝑝𝑙𝑒𝑠
at each node, leading to a total cost over the
entire trees (by summing the cost at each node) of 𝑂(𝑛
2
𝑠𝑎𝑚𝑝𝑙𝑒𝑠
𝑓𝑒𝑎𝑡𝑢𝑟𝑒𝑠
log 𝑛
𝑠𝑎𝑚𝑝𝑙𝑒𝑠
variables need to be created and blank values to be removed.
to train the tree.
analyzing datasets that have only one type of variable.
condition is easily explained by Boolean logic. By contrast, in a black box model (e.g., in an
artificial neural network), results may be more difficult to interpret.
reliability of the model.
data were generated.
CS7641 SL0 2 : Regression & Classification Mohamed Ameen Amer
try to find a mathematical relationship based on measurement points. In some
sense, Regression means “falling back to the mean”.
always be less than 1, which makes it “regression to the mean”. The best linear function would be
the one that minimizes the squared error between the data points and their corresponding
mathematical measurements.
● How to find the best linear fit?
𝑖
2
𝑛
𝑖= 1
→ Sum of Squared Errors. It’s used because it’s easy to find it’s minimum using calculus
(Squaring the differences makes this error function differentiable).
𝑖
→ The correct value of data point 𝑖.
would be just a constant 𝑐, which will result in a horizontal line across the data points.
result of our prediction function, and the actual correct value.
𝑖
𝑛
𝑖= 1
𝑖
𝑛
𝑖= 1
𝑖
𝑛
𝑖= 1
𝑛
𝑖= 1
𝑛
𝑖= 1
𝑖
𝑛
𝑖= 1
CS7641 SL0 2 : Regression & Classification Mohamed Ameen Amer
● Polynomial regression:
1
2
𝑛
), the goal is to find a set of coefficients (weights) 𝐶 =
0
1
2
𝑛
) that will produce the best approximation function 𝑓(𝑥) where:
0
1
1
2
2
𝑛
𝑛
of data points), but this will result in overfitting (Training error will decrease, and testing error
will increase).
0
1
2
2
3
3
1
1
2
1
3
2
3
2
2
3
2
2
3
3
3
𝑛
𝑛
2
𝑛
3
1
2
3
𝑛
1
2
3
𝑛
𝑇
𝑇
𝑇
− 1
𝑇
𝑇
− 1
𝑇
𝑇
− 1
𝑇
𝑇
− 1
𝑇
output.
● Regression errors:
All the datasets include error points that we don’t want to model in our algorithm. The error sources
include:
gathering/transformation.
We need to avoid fitting the error itself, we want to fit the underlying relationship.
● Cross Validation:
features), but this might lead to overfitting (Perfectly model the training data but fail to
generalize on real world data).
causing problems when generalizing to a test set.
is Independent and Identically Distributed (IID), which means that there’s no inherent difference
between training, testing and real-world data.
CS7641 SL0 2 : Regression & Classification Mohamed Ameen Amer
● Other input spaces:
So far, we’ve seen only scalar/continuous input. Other scenarios could be:
from a line on a dimensional plot, to a plan where the lower dimensions describe the vector of
inputs, and the highest describes the output.
hair color). Here are some ways to encode these attributes:
This, however, can be misleading because a correlation between the ordering of the
enumeration and the its value can be interpolated.
CS7641 SL0 3 : Neural Networks Mohamed Ameen Amer
● A perceptron is a simple computational imitation to a brain cell. It allows
computations to fire under certain stimuli, allowing for learning.
● The Perceptron calculates the sum of products of the inputs 𝑋 and their corresponding weights 𝑊,
and then compare the result with an activation threshold. If the sum is greater than or equal the
threshold 𝜃, the Perceptron fires (outputs one).
𝑖
𝑖
𝑘
𝑖= 1
● The Perceptron can be used to model Boolean functions:
1
1
2
1
1
2
3
4
1
1
CS7641 SL0 3 : Neural Networks Mohamed Ameen Amer
→ Then we can update the weights using this rule:
𝑖
𝑖
𝑖
𝑖
𝑖
→ The Perceptron Learning Rule works by adjusting the weights based on the neuron’s
performance.
→ In the best case, the difference between the predicted value 𝑦̂ and the training example 𝑦 is
zero, which means that the perceptron was able to correctly predict the value of 𝑦, so the
weight will not be updated. It keeps repeating this process till the error saturates at 0.
→ Otherwise, the weights will be adjusted (positively or negatively) to correct the error in
prediction.
→ We’ll also update this formula by adding the learning rate 𝜂. Which controls the learning
process, so that the weights get adjusted by a small value each time to avoid overshooting.
𝑖
𝑖
𝑖
𝑖
𝑖
→ The Perceptron Learning Rule works only on linearly separable datasets, where we can
separate the positive and negative examples using a straight line (or a hyperplane).
→ If the data is linearly separable, the Perceptron will eventually find the suitable line to
separate the examples.
→ The problem is, there’s no obvious way to determine if the data is linearly separable or not,
especially with higher dimensions.
→ One workaround it to run the algorithm on the data and see if it ever stops.
→ Gradient Descent is an algorithm that can work with data that isn’t linearly separable.
→ In one variable, derivative gives us the slope of the tangent line. In several variables,
Gradient (the generalization of derivatives in several variables) points towards direction of
the fastest increase of the function.
→ Let 𝐷 be the training set with ordered pairs (𝑥, 𝑦), where 𝑦 is the target value. Gradient
Descent works by taking the dot product 𝑎 of 𝑤 and 𝑥 (which is essentially a simple linear
regression), and then minimize the error of this activation using calculus.
𝑖
𝑖
𝑖
2
(𝑥,𝑦)∈𝐷
CS7641 SL0 3 : Neural Networks Mohamed Ameen Amer
→ To minimize error 𝐸(𝑤), we calculate the partial derivative of 𝐸(𝑤) with respect to each of
the individual weights (The
1
2
in the equation was added to simplify the derivative):
𝑖
𝑖
2
(𝑥,𝑦)∈𝐷
𝑖
𝑖
𝑖
𝑖
2
(𝑥,𝑦)∈𝐷
( 𝑥,𝑦
) ∈𝐷
𝑖
𝑖
𝑖
𝑖
(𝑥,𝑦)∈𝐷
𝑖
→ The error decreases fastest in the direction opposite to the gradient.
→ Robust to data that is not linearly separable.
→ Might converge to a local optima though.
→ Perceptron Learning ∆𝑤
𝑖
𝑖
→ Gradient Descent ∆𝑤
𝑖
𝑖
→ The reason we can’t use 𝑦̂ in Gradient Descent is that it will make the formula non-
differentiable.
function. So, we end up with a problem, we want the nonlinearity of the thresholded
perceptron, with the robustness of the training rule given by gradient descent.
a differentiable threshold.
−𝑎
the sigmoid rule:
𝑖
𝑖
(𝑥,𝑦)∈𝐷
CS7641 SL0 3 : Neural Networks Mohamed Ameen Amer
CS7641 SL0 3 : Neural Networks Mohamed Ameen Amer
highlights the representation power of the learning algorithm.
representing more complex data, and using hidden layers increase the representation power even
more.
model a wide variety of functions. This, however, increase the possibility of overfitting.
number of hidden layers with a bounded number of units. We can use cross validation to decide
these numbers.
of excessive training (higher magnitude of the weights). We can use cross validation to decide when
to stop training.
CS7641 SL04. Instance Based Learning Mohamed Ameen Amer
for the best generalized function 𝑓(𝑥) that can be used to predict new values.
once we receive a new value 𝑥 we lookup this database to find its corresponding 𝑦.
point and selects the best majority label.
𝑖
of 𝑁𝑁, where 𝑦
𝑖
is the most frequent
(Highest plurality - Mode).
𝑖
point is to the query point 𝑞, the more influence its 𝑦
𝑖
has on the vote/mean.
CS7641 SL04. Instance Based Learning Mohamed Ameen Amer
Algorithm Running Time Space
Learning 1 𝑛
Query log 𝑛 1
Learning 1 𝑛
Query log 𝑛 + 𝑘 1
Linear Regression
Learning n 1
Query 1 1
Eager vs Lazy Learners:
output.
performance (until we obtain more data and want to re-compute our function).
scale estimates on new data points.
decision.
function).
training data.
the target function for each query instance. Eager learners using the same hypothesis space are
more restricted because they must commit to a single hypothesis that covers the entire instance
space (depending on the training data). Eager learners can employ hypothesis spaces that combine
multiple local approximations. However, because these combined local approximations are centered
around clusters of the training instances (instead of query instances as the case with lazy learners),
they don’t give eager learners the full ability of lazy learners to generalize to unknown instances.
other hand, Linear Regression is an Eager learning algorithm, performing all learning initially to come
up the best hypothesis.