europython - machine learning for dummies with python

55
Machine Learning for dummies with Python EUROPYTHON Javier Arias @javier_arilos

Upload: javier-arias-losada

Post on 13-Feb-2017

441 views

Category:

Software


3 download

TRANSCRIPT

Page 1: Europython - Machine Learning for dummies with Python

Machine Learning

for dummieswith Python

EUROPYTHONJavier Arias

@javier_arilos

Page 2: Europython - Machine Learning for dummies with Python

One day in your life

July 2016

Page 3: Europython - Machine Learning for dummies with Python

One day in your life

Time to leave the office

Page 4: Europython - Machine Learning for dummies with Python

One day in your life

Tesla autopilot

Page 5: Europython - Machine Learning for dummies with Python

One day in your life

Playing music

Page 6: Europython - Machine Learning for dummies with Python

One day in your life

Your photos organized

Page 7: Europython - Machine Learning for dummies with Python

One day in your life

Machine Learning is here, it is everywhere andit is going to stay

Page 8: Europython - Machine Learning for dummies with Python

About this presentation

Why Machine Learning (ML) matters

A journey on Machine Learning

Some ML technologies and resources

Some basic ML concepts, with code samples

Page 9: Europython - Machine Learning for dummies with Python

Machine Learning is the next big thing

Page 10: Europython - Machine Learning for dummies with Python

Are machines already intelligent?

Page 11: Europython - Machine Learning for dummies with Python

Image-net challenge

2015: machines outperform people

Page 12: Europython - Machine Learning for dummies with Python

Chess

1997: Deepblue defeats Kasparov

Page 13: Europython - Machine Learning for dummies with Python

Game of Go

2016: AlphaGo wins world champion Lee Sedol

Page 14: Europython - Machine Learning for dummies with Python
Page 15: Europython - Machine Learning for dummies with Python

The journey

Page 16: Europython - Machine Learning for dummies with Python

Learning about ML

MOOC - Massive Open Online Courses

Contents by the best universities and companies

Udacity, Coursera, EdX

Page 17: Europython - Machine Learning for dummies with Python

Udacity - Intro to Machine Learning

Pattern Recognition for Fun and Profit

- Very well organized contents- Python + sklearn- Free- At your own pace

Page 18: Europython - Machine Learning for dummies with Python

Udacity - Intro to Machine Learning

Pattern Recognition for Fun and Profit

Page 19: Europython - Machine Learning for dummies with Python

Udacity - Intro to Machine Learning

Pattern Recognition for Fun and Profit

Page 20: Europython - Machine Learning for dummies with Python

What is Machine Learning?

Page 21: Europython - Machine Learning for dummies with Python

Solving a complex problem

somethingfeatures (data)

prediction

Page 22: Europython - Machine Learning for dummies with Python

First approach, programming

tell the computer what to do in very tiny steps

Page 23: Europython - Machine Learning for dummies with Python

programming does not scale for very complex problems...

First approach, programming

Page 24: Europython - Machine Learning for dummies with Python

Machine Learning

show the computer some real world data

the algorithm will learn from it

Page 25: Europython - Machine Learning for dummies with Python

Machine Learning, implications

we can train computers to do things we

do not know how to do

Page 26: Europython - Machine Learning for dummies with Python
Page 27: Europython - Machine Learning for dummies with Python

ML example: character recognition

Not-MNIST dataset

Thousands of 28x28 grayscale images with labels

Page 28: Europython - Machine Learning for dummies with Python

features x 1000s labels x 1000s

F G F J

ML step 1: get samples (training data)

Page 29: Europython - Machine Learning for dummies with Python

ML step 2: choose an algorithm

Linear regressionSupport Vector Mach.k-MeansDecision TreesRandom ForestsNeural networksConvolutional NNNaive Bayes

Page 30: Europython - Machine Learning for dummies with Python

ML step 3: train your algorithm

features x 1000s labels x 1000sML algorithm

F G F J

Page 31: Europython - Machine Learning for dummies with Python

ML, last step: getting predictions

ML algorithmfeatures (data)

prediction

D

Page 32: Europython - Machine Learning for dummies with Python

Tricky Question

How good are our predictions?

Page 33: Europython - Machine Learning for dummies with Python

The Tools

Page 34: Europython - Machine Learning for dummies with Python

The Tools: Python

● Opensource

● Expressive

● Interpreted, dynamically typed

● Widely used many different problems

● Batteries included: Notebook, Libraries

Page 35: Europython - Machine Learning for dummies with Python

The Tools: sklearn

● Opensource, Python

● Wonderful documentation

● Support to full ML lifecycle: ○ Feature engineering○ Algorithms○ Validation○ Datasets

Page 36: Europython - Machine Learning for dummies with Python

A summary of ML process

● Get features (with labels)

● Choose and configure an algorithm

● Train your algorithm

● Do predictions

● Validate your results

Page 37: Europython - Machine Learning for dummies with Python

train your model

tr_ds, _, tr_lbl, _ = train_test_split(dataset, labels,

train_size=size,

random_state=17)

clf = LogisticRegression()

clf.fit(tr_ds, tr_lbl) # fit with train dataset and train labels

train_ds test_ds

dataset

Page 38: Europython - Machine Learning for dummies with Python

make predictions

pred = clf.predict(test_dataset)

How good are our predictions?

Page 39: Europython - Machine Learning for dummies with Python

accuracy

test_predicions = clf.predict(test_dataset)

acc = accuracy_score(test_labels, test_predictions)

Page 40: Europython - Machine Learning for dummies with Python

89% accuracy

Page 41: Europython - Machine Learning for dummies with Python

Improving prediction results

Training data

Algorithm + config

Page 42: Europython - Machine Learning for dummies with Python
Page 43: Europython - Machine Learning for dummies with Python

Udacity - Deep Learning

Take machine Learning to the next level

ML branch based on algorithms that use multiple processing layers

● By Google

● Python and Tensorflow

● No wine for the moment :-(

Page 44: Europython - Machine Learning for dummies with Python

The Tools: TensorFlow

● Opensource, Python

● Deep Learning

● Data flow graphs.○ Nodes: mathematical operations○ Edges: Tensors, multidimensional arrays

Page 45: Europython - Machine Learning for dummies with Python

Simplest Neural Network

weight

bias

SOFTMAX

X Y PREDweight

bias

LAYER 1 LAYER 2

* + relu * + softmax

Page 46: Europython - Machine Learning for dummies with Python

Deep Learning as a chain of operations

Page 47: Europython - Machine Learning for dummies with Python

Let’s recap

Page 48: Europython - Machine Learning for dummies with Python
Page 49: Europython - Machine Learning for dummies with Python
Page 50: Europython - Machine Learning for dummies with Python
Page 51: Europython - Machine Learning for dummies with Python
Page 52: Europython - Machine Learning for dummies with Python
Page 53: Europython - Machine Learning for dummies with Python
Page 54: Europython - Machine Learning for dummies with Python
Page 55: Europython - Machine Learning for dummies with Python

Thank you for your attention