ML class overview: Difference between revisions

From John's wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 97: Line 97:
*** As we approach a local minimum, gradient descent automatically takes smaller steps
*** As we approach a local minimum, gradient descent automatically takes smaller steps
**** So no need to decrease α over time
**** So no need to decrease α over time
** [ML_class#Gradient_Descent_for_Linear_Regression|Gradient Descent for Linear Regression]
** [[ML_class#Gradient_Descent_for_Linear_Regression|Gradient Descent for Linear Regression]]
*** Gradient descent algorithm:
*** Gradient descent algorithm:
**** repeat until convergence { <math>\theta_j \colon= \theta_j - \alpha\frac{\part}{\part\theta_j}J(\theta_0,\theta_1)</math>; for j=1 and j=0 }
**** repeat until convergence { <math>\theta_j \colon= \theta_j - \alpha\frac{\part}{\part\theta_j}J(\theta_0,\theta_1)</math>; for j=1 and j=0 }
Line 104: Line 104:
**** J(<em>Θ</em><sub>0</sub>,<em>Θ</em><sub>1</sub>) = <math>\frac{1}{2m}\sum_{i=1}^m(h_\theta(x^{(i)}) - y^{(i)})^2</math>
**** J(<em>Θ</em><sub>0</sub>,<em>Θ</em><sub>1</sub>) = <math>\frac{1}{2m}\sum_{i=1}^m(h_\theta(x^{(i)}) - y^{(i)})^2</math>
**** <table style="display:inline;border:none;"><tr><td style="border:none;text-align:center;">min<br>Θ<sub>0</sub>,Θ<sub>1</sub></td><td style="border:none;">J(Θ<sub>0</sub>,Θ<sub>1</sub>)</td></tr></table>
**** <table style="display:inline;border:none;"><tr><td style="border:none;text-align:center;">min<br>Θ<sub>0</sub>,Θ<sub>1</sub></td><td style="border:none;">J(Θ<sub>0</sub>,Θ<sub>1</sub>)</td></tr></table>
*** j=0: <math>\frac{\part}{\part\theta_0}J(\theta_0,\theta_1)=\frac{1}{m}\sum_{i=1}^m(h_\theta(x^{(i)})-y^{(i)})
*** j=0: <math>\frac{\part}{\part\theta_0}J(\theta_0,\theta_1)=\frac{1}{m}\sum_{i=1}^m(h_\theta(x^{(i)})-y^{(i)})</math>
*** j=1: <math>\frac{\part}{\part\theta_1}J(\theta_0,\theta_1)=\frac{1}{m}\sum_{i=1}^m(h_\theta(x^{(i)})-y^{(i)}).x^{(i)}</math>

Revision as of 00:16, 8 October 2011

  • ML class
  • INTRODUCTION
    • Examples of machine learning
      • Database mining (Large datasets from growth of automation/web)
        • clickstream data
        • medical records
        • biology
        • engineering
      • Applications that can't be programmed by hand
        • autonomous helicopter
        • handwriting recognition
        • most of Natural Language Processing (NLP)
        • Computer Vision
      • Self-customising programs
        • Amazon
        • Netfilx product recommendations
      • Understanding human learning (brain, real AI)
    • What is Machine Learning?
      • Definitions of Machine Learning
        • Arthur Samuel (1959). Machine Learning: Field of study that gives computers the ability to learn without being explicitly programmed.
        • Tom Mitchell (1998). Well-posed Learning Problem: A computer program is said to learn from experience E with respect to some task T and some performance measure P, if its performance on on T, as measured by P, improves with experience E.
      • There are several different types of ML algorithms. The two main types are:
        • Supervised learning
          • teach computer how to do something
        • Unsupervised learning
          • computer learns by itself
      • Other types of algorithms are:
        • Reinforcement learning
        • Recommender systems
    • Supervised Learning
      • Supervised Learning in which the "right answers" are given
        • Regression: predict continuous valued output (e.g. price)
        • Classification: discrete valued output (e.g. 0 or 1)
    • Unsupervised Learning
      • Unsupervised Learning in which the categories are unknown
        • Clustering: cluster patterns (categories) are found in the data
        • Cocktail party problem: overlapping audio tracks are separated out
          • [W,s,v] = svd((repmat(sum(x.*x,1),size(x,1),1).*x)*x');
  • LINEAR REGRESSION WITH ONE VARIABLE
    • Model Representation
      • e.g. housing prices, price per square-foot
        • Supervised Learning
        • Regression
      • Dataset called training set
      • Notation:
m number of training examples
x's "input" variable / features
y's "output" variable / "target" variable
(x,y) one training example
(x(i),y(i)) ith training example
      • Training Set -> Learning Algorithm -> h (hypothesis)
      • Size of house (x) -> h -> Estimated price (y)
        • h maps from x's to y's
      • How do we represent h?
        • hΘ(x) = h(x) = Θ0 + Θ1x
      • Linear regression with one variable (x)
        • Univariate linear regression
    • Cost Function
      • Helps us figure out how to fit the best possible straight line to our data
      • hΘ(x) = Θ0 + Θ1x
      • Θi's: Parameters
      • How to choose parameters (Θi's)?
        • Choose Θ0, Θ1 so that hΘ(x) is close to y for our training examples (x,y)
        • Minimise for Θ0, Θ1
          • hΘ(x(i)) = Θ0 + Θ1x(i)
        • J(Θ0,Θ1) =
        • J(Θ0,Θ1) is the Cost Function, also known in this case as the Squared Error Function
    • Cost Function - Intuition I
      • Summary:
        • Hypothesis: hΘ(x) = Θ0 + Θ1x
        • Parameters: Θ0, Θ1
        • Cost Function: J(Θ0,Θ1) =
        • Goal: minimise Θ0, Θ1 J(Θ0, Θ1)
      • Simplified:
        • hΘ(x) = Θ1x
        • minimise Θ1 J(Θ1)
      • Can plot simplified model in 2D
    • Cost Function - Intuition II
      • Can plot J(Θ0,Θ1) in 3D
      • Can plot with Contour Map (Contour Plot)
    • Gradient Descent
      • repeat until convergence { }
      • α = learning rate
    • Gradient Descent Intuition
      • min
        Θ1
        J(Θ1)
        • For Θ1 > local minimum: positive, moves toward local minimum
        • For Θ1 < local minimum: negative, moves toward local minimum
      • If learning rate α is too small algorithm takes a long time to run
      • If learning rate α is too large algorithm may not converge or may diverge
      • When partial derivative is zero Θ1 converges
      • As we approach a local minimum, gradient descent automatically takes smaller steps
        • So no need to decrease α over time
    • Gradient Descent for Linear Regression
      • Gradient descent algorithm:
        • repeat until convergence { ; for j=1 and j=0 }
      • Linear Regression Model:
        • hΘ(x) = Θ0 + Θ1x
        • J(Θ0,Θ1) =
        • min
          Θ01
          J(Θ01)
      • j=0:
      • j=1: