Docsity

Stochastic Gradient Descent + Probabilistic Learning, Exams of Probability and Statistics

Partial preview of the text

Download Stochastic Gradient Descent + Probabilistic Learning and more Exams Probability and Statistics in PDF only on Docsity!

Stochastic Gradient Descent

Probabilistic Learning

(Binary Logistic Regression)

10 - 301/601 Introduction to Machine Learning

Matt Gormley & Henry Chai
Lecture 9
Sep. 27, 2021
Machine Learning Department
School of Computer Science
Carnegie Mellon University

Reminders

  • Homework 3: KNN, Perceptron, Lin.Reg.
    • Out: Mon, Sep. 20
    • Due: Sun, Sep. 26 at 11:59pm
    • IMPORTANT: you may only use 2 grace days on Homework 3 - last possible moment to submit HW3: Tue, Sep. 28 at 11:59pm
  • Practice for Exam
    • Mock Exam 1
      • Released Sun, Sep. 26
      • Due Wed, Sep. 29 at 11:59pm
      • See @491 for participation point details
    • Practice problems released on course website
  • Midterm Exam 1
    • Thu, Sep. 30, 6:30pm โ€“ 8:30pm

Midterm Exam

  • Time / Location
    • Time: Thursday, September 30, at 6:30pm - 8:30pm
    • Location & Seats: You have all been split across 5 rooms:
McConomy auditorium, DH 2315, DH 2210, DH 2105 & DH 2122.
Everyone has an assigned seat in one of these rooms; see
@506 for details.
  • Please watch Piazza carefully for announcements.
  • Logistics
  • Covered material: Lecture 1 โ€“ Lecture 8
  • Format of questions:
  • Multiple choice
  • True / False (with justification)
  • Derivations
  • Short answers
  • Interpreting figures
  • Implementing algorithms on paper

Midterm Exam

  • How to Prepare
    • Attend the midterm review lecture (right now!)
    • Participate in the Mock Exam
    • Review exam practice problems
    • Review this yearโ€™s homework problems
    • Consider whether you have achieved the โ€œlearning objectivesโ€ for each lecture / section
    • Write your one-page cheat sheet (back and front)

Topics for Midterm 1

  • Foundations
    • Probability, Linear Algebra, Geometry, Calculus
    • Optimization
  • Important Concepts
    • Overfitting
    • Experimental Design
      • Classification
        • Decision Tree
        • KNN
        • Perceptron
      • Regression
        • Linear Regression

SAMPLE QUESTIONS

Sample Questions 10-701 Machine Learning Midterm Exam - Page 8 of 17 11/02/ Now we will apply K-Nearest Neighbors using Euclidean distance to a binary classifi- cation task. We assign the class of the test point to be the class of the majority of the k nearest neighbors. A point can be its own neighbor. Figure 5

  1. [2 pts] What value of k minimizes leave-one-out cross-validation error for the dataset shown in Figure 5? What is the resulting error? 10-701 Machine Learning Midterm Exam - Page 7 of 17 11/02/ 4 K-NN [12 pts] In this problem, you will be tested on your knowledge of K-Nearest Neighbors (K-NN), where k indicates the number of nearest neighbors.
  2. [3 pts] For K-NN in general, are there any cons of using very large k values? Select one. Briefly justify your answer. (a) Yes (b) No
  3. [3 pts] For K-NN in general, are there any cons of using very small k values? Select one. Briefly justify your answer. (a) Yes (b) No

Sample Questions

17

10-601: Machine Learning Page 7 of 16 2/29/

3 Linear and Logistic Regression [20 pts. + 2 Extra Credit] 3.1 Linear regression

Given that we have an input x and we want to estimate an output y, in linear regression

we assume the relationship between them is of the form y = wx + b + โœ, where w and b are real-valued parameters we estimate and โœ represents the noise in the data. When the noise is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min

w

X^ n

i=

(yi (wxi + b))

2

.

Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line. Given that we have an input x and we want to estimate an output y, in linear regression we assume the relationship between them is of the form y = wx + b + โœ, where w and b are real-valued parameters we estimate and โœ represents the noise in the data. When the noise is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min

w

X^ n

i=

(yi (wxi + b))^2.

Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line.

new

10-601: Machine Learning Page 8 of

(a) Adding one outlier to the original data set. (b) set. Dataset

real-valued parameters we estimate and โœ represents the noise in the data. When the noise

is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min

w

X^ n

i=

(yi (wxi + b))^2.

Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line. Figure 2: New regression lines for altered data sets Snew.

rning Page 7 of 16 2/29/

gistic Regression [20 pts. + 2 Extra Credit]

ession

put x and we want to estimate an output y, in linear regression hip between them is of the form y = wx + b + โœ, where w and b are s we estimate and โœ represents the noise in the data. When the noise g the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate b is equivalent to minimizing the squared error: arg min w X^ n i= (yi (wxi + b))^2. t S plotted in Fig. 1 along with its associated regression line. For ets Snew^ plotted in Fig. 3 , indicate which regression line (relative g. 2 corresponds to the regression line for the new data set. Write e below. Dataset (a) (b) (c) (d) (e) Regression line An observed data set and its associated regression line. 10-601: Machine Learning Page 7 of 16 2/29/

3 Linear and Logistic Regression [20 pts. + 2 Extra Credit]

3.1 Linear regression

Given that we have an input x and we want to estimate an output y, in linear regression we assume the relationship between them is of the form y = wx + b + โœ, where w and b are real-valued parameters we estimate and โœ represents the noise in the data. When the noise is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min w X^ n i= (yi (wxi + b))^2. Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line. 10-601: Machine Learning Page 7 of 16 2/29/

3 Linear and Logistic Regression [20 pts. + 2 Extra Credit]

3.1 Linear regression

Given that we have an input x and we want to estimate an output y, in linear regression we assume the relationship between them is of the form y = wx + b + โœ, where w and b are real-valued parameters we estimate and โœ represents the noise in the data. When the noise is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min w X^ n i= (yi (wxi + b))^2. Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line.

Sample Questions

19

10-601: Machine Learning Page 7 of 16 2/29/

3 Linear and Logistic Regression [20 pts. + 2 Extra Credit] 3.1 Linear regression

Given that we have an input x and we want to estimate an output y, in linear regression

we assume the relationship between them is of the form y = wx + b + โœ, where w and b are real-valued parameters we estimate and โœ represents the noise in the data. When the noise is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min

w

X^ n

i=

(yi (wxi + b))

2

.

Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line. Given that we have an input x and we want to estimate an output y, in linear regression we assume the relationship between them is of the form y = wx + b + โœ, where w and b are real-valued parameters we estimate and โœ represents the noise in the data. When the noise is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min

w

X^ n

i=

(yi (wxi + b))^2.

Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line.

new (a) Adding one outlier to the original data set. (b) Adding two outliers to the original data set. (c) Adding three outliers to the original data set. Two on one side and one on the other side. (d) Duplicating the original data set. Dataset

real-valued parameters we estimate and โœ represents the noise in the data. When the noise

is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min

w

X^ n

i=

(yi (wxi + b))^2.

Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line. Figure 2: New regression lines for altered data sets Snew.

rning Page 7 of 16 2/29/

gistic Regression [20 pts. + 2 Extra Credit]

ession

put x and we want to estimate an output y, in linear regression hip between them is of the form y = wx + b + โœ, where w and b are s we estimate and โœ represents the noise in the data. When the noise g the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate b is equivalent to minimizing the squared error: arg min w X^ n i= (yi (wxi + b))^2. t S plotted in Fig. 1 along with its associated regression line. For ets Snew^ plotted in Fig. 3 , indicate which regression line (relative g. 2 corresponds to the regression line for the new data set. Write e below. Dataset (a) (b) (c) (d) (e) Regression line An observed data set and its associated regression line. 10-601: Machine Learning Page 7 of 16 2/29/

3 Linear and Logistic Regression [20 pts. + 2 Extra Credit]

3.1 Linear regression

Given that we have an input x and we want to estimate an output y, in linear regression we assume the relationship between them is of the form y = wx + b + โœ, where w and b are real-valued parameters we estimate and โœ represents the noise in the data. When the noise is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min w X^ n i= (yi (wxi + b))^2. Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line. 10-601: Machine Learning Page 7 of 16 2/29/

3 Linear and Logistic Regression [20 pts. + 2 Extra Credit]

3.1 Linear regression

Given that we have an input x and we want to estimate an output y, in linear regression we assume the relationship between them is of the form y = wx + b + โœ, where w and b are real-valued parameters we estimate and โœ represents the noise in the data. When the noise is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min w X^ n i= (yi (wxi + b))^2. Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line.

Sample Questions

20

10-601: Machine Learning Page 7 of 16 2/29/

3 Linear and Logistic Regression [20 pts. + 2 Extra Credit] 3.1 Linear regression

Given that we have an input x and we want to estimate an output y, in linear regression

we assume the relationship between them is of the form y = wx + b + โœ, where w and b are real-valued parameters we estimate and โœ represents the noise in the data. When the noise is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min

w

X^ n

i=

(yi (wxi + b))

2

.

Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line. Given that we have an input x and we want to estimate an output y, in linear regression we assume the relationship between them is of the form y = wx + b + โœ, where w and b are real-valued parameters we estimate and โœ represents the noise in the data. When the noise is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min

w

X^ n

i=

(yi (wxi + b))^2.

Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line.

new (c) Adding three outliers to the original data set. Two on one side and one on the other side. (d) Duplicating the o (e) Duplicating the original data set and adding four points that lie on the trajectory of the original regression line.

Figure 3: New data set Snew.

Dataset

real-valued parameters we estimate and โœ represents the noise in the data. When the noise

is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min

w

X^ n

i=

(yi (wxi + b))^2.

Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line. Figure 2: New regression lines for altered data sets Snew.

rning Page 7 of 16 2/29/

gistic Regression [20 pts. + 2 Extra Credit]

ession

put x and we want to estimate an output y, in linear regression hip between them is of the form y = wx + b + โœ, where w and b are s we estimate and โœ represents the noise in the data. When the noise g the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate b is equivalent to minimizing the squared error: arg min w X^ n i= (yi (wxi + b))^2. t S plotted in Fig. 1 along with its associated regression line. For ets Snew^ plotted in Fig. 3 , indicate which regression line (relative g. 2 corresponds to the regression line for the new data set. Write e below. Dataset (a) (b) (c) (d) (e) Regression line An observed data set and its associated regression line. 10-601: Machine Learning Page 7 of 16 2/29/

3 Linear and Logistic Regression [20 pts. + 2 Extra Credit]

3.1 Linear regression

Given that we have an input x and we want to estimate an output y, in linear regression we assume the relationship between them is of the form y = wx + b + โœ, where w and b are real-valued parameters we estimate and โœ represents the noise in the data. When the noise is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min w X^ n i= (yi (wxi + b))^2. Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line. 10-601: Machine Learning Page 7 of 16 2/29/

3 Linear and Logistic Regression [20 pts. + 2 Extra Credit]

3.1 Linear regression

Given that we have an input x and we want to estimate an output y, in linear regression we assume the relationship between them is of the form y = wx + b + โœ, where w and b are real-valued parameters we estimate and โœ represents the noise in the data. When the noise is Gaussian, maximizing the likelihood of a dataset S = {(x 1 , y 1 ),... , (xn, yn)} to estimate the parameters w and b is equivalent to minimizing the squared error: arg min w X^ n i= (yi (wxi + b))^2. Consider the dataset S plotted in Fig. 1 along with its associated regression line. For each of the altered data sets Snew^ plotted in Fig. 3 , indicate which regression line (relative to the original one) in Fig. 2 corresponds to the regression line for the new data set. Write your answers in the table below. Dataset (a) (b) (c) (d) (e) Regression line Figure 1: An observed data set and its associated regression line.

OPTIMIZATION METHOD #3: STOCHASTIC GRADIENT DESCENT

Stochastic Gradient Descent (SGD)

In practice, it is common
to implement SGD using
sampling without
replacement (i.e.
shuffle({1,2,โ€ฆN}), even
though most of the
theory is for sampling
with replacement (i.e.
Uniform({1,2,โ€ฆN}).

Per-example objective:! "

Original objective:!^ #^ =^ % "&' ( ! "