Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine...

71
1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data NumPy, pandas and matplotlib tutorials Understanding the pandas module Exploring data

Transcript of Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine...

Page 1: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

1 Introduction to Practical

Machine Learning using Python

Preparing, manipulating and visualizing data – NumPy, pandas and matplotlib tutorials

Understanding the pandas module

Exploring data

Page 2: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 3: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 4: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 5: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 6: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 7: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Manipulate data

Page 8: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 9: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 10: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 11: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 12: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Matplotlib tutorial

Example of simple plot

Page 13: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Example of plot with multiple lines

Page 14: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Scatter plot of randomly distributed points

Page 15: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

2 Machine Learning Techniques –

Unsupervised

Learning Clustering algorithms

Density methods

Mean – shift

Sketch of the mean-shift evolution through iterations

Page 16: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Hierarchical methods

Page 17: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Training and comparison of the clustering methods

Two multivariate normal classes with noise

Page 18: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

IClustering of the two multivariate classes using k-means, mean-shift, Gaussian mixture model, and hierarchical ward

method

IHierarchical clustering dendrogram for the last 12 merges.

Page 19: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Dimensionality reduction

Principal Component Analysis (PCA)

The linear function between the velocity in m/s and Km/h

Page 20: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

PCA example

A two-dimensional dataset. The principal component direction v1 is indicated by an arrow.

Page 21: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

3 Supervised Machine Learning

Model error estimation

Variance and bias example.

Page 22: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Decision trees

Decision tree for predicting whether to bring an umbrella or not based on a record of 100 days.

Support vector machine

Sketch of the dataset separated in two classes (empty and filled circles) by the black line (decision boundary)

Page 23: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

The predictions lie around the true value

Kernel trick

Page 24: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

In a two-dimensional space, the dataset shown on the left is not separable. Mapping the dataset in a three-dimensional

space, the two classes are separable.

A comparison of methods

Regression problem

Page 25: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 26: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 27: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 28: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Classification problem

Page 29: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 30: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 31: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 32: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Hidden Markov model

Salesman behavior – two states hidden Markov model

Page 33: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

4 Web Mining Techniques

Natural language processing

Page 34: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Information retrieval models

Word2vec – continuous bag of words and skip-gram architectures

skip-gram (left) and CBOW (right) architectures of the word2vec algorithm; figures taken from word2vec Parameter

Learning Explained by X Rong (2015)

Doc2Vec extension

Page 35: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

A distributed memory model example with a context of three words (window=3); figure taken from Distributed Representations of Sentences and Documents by Le and Mikolov (2014)

Movie review query example

Page 36: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 37: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 38: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 39: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Postprocessing information

Latent Dirichlet allocation

Example

Page 40: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 41: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Opinion mining (sentiment analysis)

Page 42: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 43: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 44: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 45: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

5 Recommendation Systems

Utility matrix

Page 46: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Similarities measures

Page 47: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Collaborative Filtering methods

Memory-based collaborative filtering

User based collaborative filtering

Page 48: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Item based collaborative filtering

Page 49: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Simplest item-based collaborative filtering: slope one

Page 50: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Model-based Collaborative Filtering

Alternative least square (ALS)

Stochastic gradient descent (SGD)

Page 51: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Non-negative matrix factorization (NMF)

Singular value decomposition (SVD)

Page 52: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Content-based Filtering (CBF) methods

Item's features average method

Page 53: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Regularized linear regression method

Page 54: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Association rules learning recommendation system

Page 55: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Log-likelihood ratios recommendation system method

Page 56: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Hybrid recommendation systems

Page 57: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 58: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Evaluation of the recommendation systems

Page 59: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Root mean square error (RMSE) evaluation

Page 60: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 61: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 62: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Classification metrics

Page 63: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

6 Getting Started with Django

Writing an app – most important features

URL and views behind HTML web pages

HTML pages

Page 64: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Admin

Page 65: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

RESTful application programming interfaces (APIs)

Page 66: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

7 Movie Recommendation System Web Application

User sign up login/logout implementation

Page 67: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Information retrieval system (movies query)

Page 68: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Recommendation systems

Admin interface and API

Page 69: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

8 Sentiment Analyser application

on Movie Reviews

Application's usage overview

Page 70: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas
Page 71: Introduction to Practical Machine Learning using Python€¦ · 1 Introduction to Practical Machine Learning using Python Preparing, manipulating and visualizing data – NumPy, pandas

Admin and API