Artificial Intelligence & Machine Learning, Zusammenfassungen von Künstliche Intelligenz

Toggle sidebar
bg1
3/13/2026
1
Fundamental Algorithms – I
Dr. Berke Gür
Artificial Intelligence & Machine Learning
Dr. Berke Gür
3/13/2026
1
Chapter Overview
•Fundamental ML algorithms are introduced
–Linear regression
–Logistic regression
–Decision trees
–Support vector machines (SVM)
–kth nearest neighbor
•Using these algorithms, one can perform both regression &
classification
Artificial Intelligence & Machine Learning
Dr. Berke Gür
3/13/2026
2
1
2
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Unvollständige Textvorschau

Nur auf Docsity: Lade Artificial Intelligence & Machine Learning und mehr Zusammenfassungen als PDF für Künstliche Intelligenz herunter!

1

Fundamental Algorithms – I

Dr. Berke Gür Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 1

Chapter Overview

  • Fundamental ML algorithms are introduced
    • Linear regression
    • Logistic regression
    • Decision trees
    • Support vector machines (SVM)
    • kth nearest neighbor
  • Using these algorithms, one can perform both regression & classification Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 2 1

2

Fundamental Algorithms

  • In this chapter, basic algorithms for regression & classification is introduced
  • To specify an algorithm, one must specify
    • The model
    • The cost function, and
    • An optimization method
  • The algorithms introduced in this chapter are viewed from this perspective Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 3

Cost Functions

  • A loss function is the criterion to be optimized
  • But a loss function is defined for a single sample
    • Ex: squared error, ei = [yi − (w∙xi + b)]^2
  • An optimization criterion is the loss function defined over the entire training data set - Ex: Mean Square Error Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 4 2 , 1 1 [ ( )] N i b i i y f N (^) 

    w x

3

4

Linear Regression – Model

  • Assume that we have a collection of labeled data {(xi, yi)}Ni = 1 where N is the size of the collection - xi be the D-dimensional feature vector of example i (i = 1, 2, … , N) - yi is the corresponding real-valued target (yi ∈ ℝ) - Every feature xi(^ j), ( j = 1, 2, … , D) is also a real number
  • Build a model fw,b(x) as a linear combination of features of example x
    • where w is a D-dimensional vector of parameters (called weights)
    • b is a real number (called the bias)
  • The notation fw,b(x) means that the model f (x) is parametrized by the two values w & b Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 9 f (^) w , b( )x  w x b

Linear Regression – Model

  • The objective is to find the optimal values (w, b) that result in the most accurate predictions of y
  • The optimal values (w, b) are called the statistical model or just model for short
  • The process of obtaining these values or building the model is called training Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 10 9

5

Linear Regression – Model

  • The hyperplane in linear regression is chosen to be as close to all training examples as possible
  • This regression hyperplane line is used to predict the value of the target ynew for a new unlabeled input example xnew Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 11

Linear Regression – Model

  • If the feature vector is 1-D (i.e., xi is a scalar or xi) the hyperplane is a line
  • If the examples are D-dimensional feature vectors (for D > 1), the regression model is not a line but a - Plane (for D = 2) - Hyperplane (for D > 2) Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 12 11

7

Squared Error Loss Function

  • Squaring the errors emphasized them & prevents positive & negative error cancellations
  • But so does the absolute value
    • The absolute value is not used because it doesn’t have a continuous derivative which makes the function not smooth
    • Functions that are not smooth create unnecessary difficulties when employing linear algebra to find closed form solutions to optimization problems
  • Closed form solutions to finding an optimum of a function are simple algebraic expressions and are often preferable to using complex numerical optimization methods such as gradient descent (used, among others, to train neural networks) Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 15

Linear Regression with MATLAB

  • The mldivide () operator can be used in MATLAB to perform linear regression
  • The mldivide function is the same as inv( ) function but more efficient
  • Consider the following models
    • No bias model of the form y = w∙x
    • With bias model of the form y = w∙x + b
  • The models are evaluated using the coefficient of determination (R^2 ) statistic Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 16 2 , (^2 ) 2 1 [ ( )] 1 ( ) N i b i i N i i y f R y y      

w x 15

8

Ex: Linear Regression with 1-D Features (D = 1)

Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 17 2 2 ,

w w b R R  

Ex: Linear Regression with 2-D Features (D = 2)

Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 18 2 2 ,

b^ 1. R R   w w 17

10

Logistic Regresion – Cost Function

  • Recall the MSE cost function of linear regression
  • Using the MSE cost function in logistic regression is not viable
  • This is because the MSE would result in a non-convex optimization function with many local minimums
  • It would be very difficult to minimize the cost value and find the global minimum Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 22 2 , 1 1 [ ( ) ] N b i i i f y N (^) 

   w x 

Likelihood

  • Choose (w, b) that will maximize the likelihood of our training set based on the model
  • In statistics the likelihood function defines how likely the observation (an example) is according to our model
  • Assume that we have some model (w 0 , b 0 )
  • Assume that this model gives an output (p) such that 0 < p < 1 for a labeled example (xi, yi) - If (yi) is actually from the positive class, the likelihood of (yi) being classified as positive class (according to our model) is given by (p) - Similarly, if (yi) is the negative class, the likelihood of (yi) being the negative class is given by (1 − p) Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 23 22

11

Logistic Regresion – Cost Function

  • The optimization criterion in logistic regression is called maximum likelihood
  • Instead of minimizing the average loss (i.e., linear regression), the likelihood of the training data (according to the model) is maximized to find optimal values (w, b)
  • The product operator (∏) is used because the likelihood of observing N labels for N examples is the product of likelihoods of each observation (assuming that all observations are independent of one another) Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 24 1 , , 1 [ ( )] [1i^ ( )] i N y y b i b i i f f  

   w x  w x

The likelihood function is also the probability mass function associated with the Bernoulli distribution

Logistic Regresion – Optimization

  • It is more convenient to maximize the log-likelihood instead of likelihood because of the presence of the exp(·) function in the model
  • The log-likelihood is defined as follows
  • There is no difference between maximizing the likelihood or the log likelihood functions because ln(·) or loge is a strictly increasing Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 25 , , 1 ln ( ) { ln[ ( )] (1 ) ln[1 ( )]} N i b i i b i i y f y f 

 x   w x    w x

24

Lecture Summary

  • Introduction to the basic components of learning algorithms
    • The model
    • Loss & cost functions
    • Optimization methods
  • Description of fundamental machine learning (ML) algorithms
    • Linear regression
    • Logistics regression Artificial Intelligence & Machine Learning Dr. Berke Gür 3/13/ 28 28