pybcn machine learning for dummies with python

72
<>CDI@@<MIDIB AJM?PHHD@N RDOCTOCJI <QD@MMD<N E<QD@M›<MDGJN

Upload: javier-arias-losada

Post on 08-Feb-2017

518 views

Category:

Technology


6 download

TRANSCRIPT

Page 1: Pybcn machine learning for dummies with python

Machine Learning

for dummieswith Python

PYBCNJavier Arias

@javier_arilos

Page 2: Pybcn machine learning for dummies with python

One day in your life

June 2016

Page 3: Pybcn machine learning for dummies with python

One day in your life

Time to leave the office

Page 4: Pybcn machine learning for dummies with python

One day in your life

Tesla autopilot

Page 5: Pybcn machine learning for dummies with python

One day in your life

Page 6: Pybcn machine learning for dummies with python

One day in your life

Playing music

Page 7: Pybcn machine learning for dummies with python

One day in your life

Your photos organized

Page 8: Pybcn machine learning for dummies with python

One day in your life

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

Page 9: Pybcn 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 sample

Page 10: Pybcn machine learning for dummies with python

Machine Learning is the next big thing

Page 11: Pybcn machine learning for dummies with python

Are machines already intelligent?

Page 12: Pybcn machine learning for dummies with python

Image-net challenge

2015: machines outperform people

Page 13: Pybcn machine learning for dummies with python

Chess

1997: Deepblue defeats Kasparov

Page 14: Pybcn machine learning for dummies with python

Game of Go

2016: AlphaGo wins world champion Lee Sedol

Page 15: Pybcn machine learning for dummies with python
Page 16: Pybcn machine learning for dummies with python

The journey

Page 17: Pybcn machine learning for dummies with python

Learning about ML

MOOC - Massive Open Online Courses

Contents by the best universities and companies

Some superstar teachers

Udacity, Coursera, EdX

Page 18: Pybcn machine learning for dummies with python

Udacity - Intro to Machine Learning

Pattern Recognition for Fun and Profit

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

Page 19: Pybcn machine learning for dummies with python

Udacity - Intro to Machine Learning

Pattern Recognition for Fun and Profit

Page 20: Pybcn machine learning for dummies with python

Udacity - Intro to Machine Learning

Pattern Recognition for Fun and Profit

Page 21: Pybcn 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 22: Pybcn machine learning for dummies with python

What is Machine Learning?

Page 23: Pybcn machine learning for dummies with python

Solving a complex problem

somethingfeatures (data)

prediction

Page 24: Pybcn machine learning for dummies with python

First approach, programming

tell the computer what to do in very tiny steps

Page 25: Pybcn machine learning for dummies with python

… represented primarily as if-then rules ...

Artificial Intelligence - expert systems

Page 26: Pybcn machine learning for dummies with python

Machine Learning

show the computer some real world data and let it learn from it

Page 27: Pybcn machine learning for dummies with python

Machine Learning, implications

We can train computers to do things we do not know how to do

Page 28: Pybcn machine learning for dummies with python
Page 29: Pybcn machine learning for dummies with python

ML example: character recognition

Not-MNIST dataset

Thousands of 28x28 grayscale images with labels

Page 30: Pybcn machine learning for dummies with python

features x 1000s labels x 1000s

F G F J

ML step 1: get samples (training data)

Page 31: Pybcn machine learning for dummies with python

ML step 2: choose an algorithm

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

Page 32: Pybcn machine learning for dummies with python

ML step 3: train your algorithm

features x 1000s labels x 1000sML algorithm

F G F J

Page 33: Pybcn machine learning for dummies with python

ML, last step: getting predictions

ML algorithmfeatures (data)

prediction

D

Page 34: Pybcn machine learning for dummies with python

Tricky Question

How good are our predictions?

Page 35: Pybcn machine learning for dummies with python

The Tools

Page 36: Pybcn machine learning for dummies with python

The Tools

Python sklearn tensorflow

Page 37: Pybcn machine learning for dummies with python

The Tools: Python

● Opensource

● Expressive

● Interpreted, dynamically typed

● Widely used many different problems

● Batteries included: Notebook, Libraries

Page 38: Pybcn machine learning for dummies with python

The Tools: sklearn

● Opensource, Python

● Wonderful documentation

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

Page 39: Pybcn machine learning for dummies with python

The Tools: TensorFlow

● Opensource, Python

● Deep Learning

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

Page 40: Pybcn machine learning for dummies with python
Page 41: Pybcn 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 42: Pybcn 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 43: Pybcn machine learning for dummies with python

make predictions

pred = clf.predict(test_dataset)

How good are our predictions?

Page 44: Pybcn machine learning for dummies with python

accuracy

test_predicions = clf.predict(test_dataset)

acc = accuracy_score(test_labels, test_predictions)

Page 45: Pybcn machine learning for dummies with python

89% accuracy

Page 46: Pybcn machine learning for dummies with python

Improving prediction results

Training data

Algorithm + config

Page 47: Pybcn machine learning for dummies with python

Is Machine Learning black magic?

Page 48: Pybcn machine learning for dummies with python

Machine Learning is mathematics

Page 49: Pybcn machine learning for dummies with python

Linear regression - predict house prices

Page 50: Pybcn machine learning for dummies with python

Linear regression

Page 51: Pybcn machine learning for dummies with python

Linear regression

price = m·size + n

Page 52: Pybcn machine learning for dummies with python

Linear regression - starting training

Page 53: Pybcn machine learning for dummies with python

Linear regression - training iteration

Page 54: Pybcn machine learning for dummies with python

Linear regression - error minimized

Page 55: Pybcn machine learning for dummies with python

SVM classification example

Page 56: Pybcn machine learning for dummies with python

ML finds boundaries in your data

Page 57: Pybcn machine learning for dummies with python
Page 58: Pybcn machine learning for dummies with python

89% accuracy… It can never be too much.

Page 59: Pybcn machine learning for dummies with python

First trained algorithm - 30% accuracy

Page 60: Pybcn machine learning for dummies with python

75% accuracy - should we aim for 100%?

Page 61: Pybcn machine learning for dummies with python

100% accuracy, now we are talking!

Page 62: Pybcn machine learning for dummies with python

overfitting

Page 63: Pybcn machine learning for dummies with python

Let’s recap

Page 64: Pybcn machine learning for dummies with python
Page 65: Pybcn machine learning for dummies with python
Page 66: Pybcn machine learning for dummies with python
Page 67: Pybcn machine learning for dummies with python
Page 68: Pybcn machine learning for dummies with python
Page 69: Pybcn machine learning for dummies with python
Page 70: Pybcn machine learning for dummies with python
Page 71: Pybcn machine learning for dummies with python

Questions?

Page 72: Pybcn machine learning for dummies with python