Machine Learning

Introduction

What is machine learning?









Field of study that gives computers the ability to learn without being explicitly programmed.
Arthur Samuel








A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P if its performance at tasks in T, as measured by P, improves with experience E".
Tom M. Mitchell








The science and engineering of making intelligent machines.
John McCarthy about A.I.

Why so important?

To automate

ML infers rules from data
(implicit programming)

To make machines smart!

what is smart? What is intelligent?

Computer vision

Diagnostics

Recommendation

Coming soon...

Robot revolution?

I'm going to start worrying [...] the day my computer becomes aware of my printer."
Andrew McAfee

Welcome to the jungle

How does it work?

  • Data in --> Model out
  • Model training and validation
  • Supervised vs. Unsupervised
  • Going live
Data in --> Model out
Supervised vs Unsupervised
FeaturesTarget
Sex Height Weight Age Sport
M 1.67 60 20 soccer
F 1.95 90 28 basket
M 1.80 79 23 soccer
... ... ... ... ...
F 1.85 78 25 ???
Supervised vs Unsupervised
Features
Sex Height Weight Age Sport
M 1.67 60 20 soccer
F 1.95 90 28 basket
M 1.80 79 23 soccer
... ... ... ... ...
??? ??? ??? ??? ???
Training and Validation
Training and Validation

Going live

  • You can train the model with a language...
    (python wrappers of C++ libs, running on a cluster)
  • ... and use it with another!
    (Javascript on mobile)
  • REST APIs, microservices

Inside the black box...

  • Linear algebra
  • Calculus
  • Probability

Linear algebra

Vectors and matrices
It's all about points in space and their distance/transformation

Calculus

Derivatives, optimization
It's all about changing parameters to minimize an error

Probability

Bayes
It's all about confidence

Don't be scared

  • It's just (a lot of) simple ideas
  • Math is just a compact representation


\[\bar{x} = \frac{\sum_\limits{i=1}^{n} x_i}{n}\]

function average(x) {
    
    var n   = x.length;
    var sum = 0.0;

    for(var i=0; i<n; i++){
        sum += x[i];
    }

    return sum/n;
    // TODO: don't divide by zero
}
                            

Don't be scared

EYES HAIR
green red
green black
black black
green red


\[P(E_g|H_r) = \frac{P(E_g, H_r)}{P(H_r)}\]


function conditional_probability($eyes="green", $hair="red"){
    $prob_H =
      sql("SELECT COUNT(*) FROM table WHERE HAIR=$hair");
    
    $prob_E_and_H =
      sql("SELECT COUNT(*) FROM table WHERE EYES=$eyes AND HAIR=$hair");
    
    return $prob_E_and_H / $prob_H;
}
                            

Applications