100
Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June 2018

Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Statistical methods for big data

in life sciences and health with R

Philippe Jacquet

Data Scientist at CADMOS

June 2018

Page 2: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

CADMOS

CADMOS: Center for Advanced Modeling Of Science

Page 3: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

CADMOS

CADMOS: Center for Advanced Modeling Of Science

Free service for all UNIL, EPFL and UNIGE researchers

Page 4: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

CADMOS

CADMOS: Center for Advanced Modeling Of Science

Free service for all UNIL, EPFL and UNIGE researchers

Help with HPC parallel computing (code optimization) orBig Data analysis (pipeline development), including somecomputing power at SCITAS (the EPFL cluster)

Page 5: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

CADMOS

CADMOS: Center for Advanced Modeling Of Science

Free service for all UNIL, EPFL and UNIGE researchers

Help with HPC parallel computing (code optimization) orBig Data analysis (pipeline development), including somecomputing power at SCITAS (the EPFL cluster)

Contact:UNIL: [email protected], [email protected]: [email protected]: [email protected]

Page 6: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Outline

TODAY

13:30 – 15:00 Lecture on Neural Network

15:00 – 15:30 Coffee break

15:30 – 17:00 Practicals on Neural Network

Page 7: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Outline

TODAY

13:30 – 15:00 Lecture on Neural Network

15:00 – 15:30 Coffee break

15:30 – 17:00 Practicals on Neural Network

TOMORROW (Room 321 - Amphipôle)

09:00 – 10:30 Lecture on Decision Tree and Random Forest

10:30 – 11:00 Coffee break

11:00 – 12:30 Practicals on Decision Tree and Random Forest

Page 8: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Outline

If you have any question during the lecture

you are welcome to ask

Page 9: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Outline

We will analyse the same dataset (iris data)

with all the methods

Page 10: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Outline

And present some applications

in health science

Page 11: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

The iris dataset

Page 12: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

The iris dataset

4 measurements on 50 flowers in 3 species

Page 13: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

The iris dataset

Sepal length Sepal width Petal length Petal width Species

5.1 3.5 1.4 0.2 setosa

7.0 3.2 4.7 1.4 versicolor

6.3 3.3 6.0 2.5 virginica

Page 14: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

The iris dataset

Sepal length Sepal width Petal length Petal width Species

5.1 3.5 1.4 0.2 setosa

7.0 3.2 4.7 1.4 versicolor

6.3 3.3 6.0 2.5 virginica

input output

Page 15: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

The iris dataset

GOAL

Given an input (4 measurements)

predict its output (species)

Page 16: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Machine learning

MACHINE LEARNING

UNSUPERVISED LEARNING- only input data- explorative models: clustering, dim. reduction

Page 17: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Machine learning

MACHINE LEARNING

UNSUPERVISED LEARNING- only input data- explorative models: clustering, dim. reduction

SUPERVISED LEARNING- input data + output data- predictive models: classi�cation, regression

Page 18: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Data splitting:

train validation test

0 60% 80% 100%

model selection model assessementmodel training

Page 19: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Data splitting:

train validation test

0 60% 80% 100%

model selection model assessementmodel training

Model training: estimate the model parameters

Page 20: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Data splitting:

train validation test

0 60% 80% 100%

model selection model assessementmodel training

Model training: estimate the model parameters

Model selection: estimate the performance of differentmodels in order to choose the best one

Page 21: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Data splitting:

train validation test

0 60% 80% 100%

model selection model assessementmodel training

Model training: estimate the model parameters

Model selection: estimate the performance of differentmodels in order to choose the best one

Model assessment: having chosen a final model, estimateits prediction accuracy on new data

Page 22: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

EXAMPLE

Page 23: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model 1= Neural Network

Page 24: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model 1= Neural Network

Estimate the model parameters using the training set

Page 25: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model 1= Neural Network

Estimate the model parameters using the training set

Measure the model accuracy based on the validation set

Page 26: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model 2 = Decision Tree

Page 27: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model 2 = Decision Tree

Estimate the model parameters using the training set

Measure the model accuracy based on the validation set

Page 28: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model 3 = Random Forest

Page 29: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model 3 = Random Forest

Estimate the model parameters using the training set

Measure the model accuracy based on the validation set

Page 30: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model Selection

Page 31: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model Selection

Select the best model based on its accuracy

Page 32: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model Selection

Select the best model based on its accuracy

Neural Network = Decision Tree

Page 33: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model Assessment

Page 34: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model Assessment

Mesure best model accuracy on the test set

Page 35: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Supervised learning

Model Assessment

Mesure best model accuracy on the test set

THE END

Page 36: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

How to build a neural network

for the iris data ?

Page 37: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

y1

y2

y3

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Page 38: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerMany Hidden Layers

y1

y2

y3

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Deep Learning = More than 1 Hidden Layer

Page 39: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

y1

y2

y3

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Page 40: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights Weights

Page 41: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

Page 42: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

Soft

Max

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

Page 43: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

What is

the mathematical formula

for this neural network ?

Page 44: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

Soft

Max

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

X W(1) Z(1) ReLU Z(2) W(2) Z(3) SoftMAX Y

Page 45: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

Soft

Max

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

W(1) Z(1) ReLU Z(2) W(2) Z(3) SoftMAX Y

X

Page 46: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

Soft

Max

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

Z(1) ReLU Z(2) W(2) Z(3) SoftMAX Y

W (1)X

Page 47: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

Soft

Max

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

ReLU Z(2) W(2) Z(3) SoftMAX Y

Z (1)

� �� �W (1)X

Page 48: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

Soft

Max

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

Z(2) W(2) Z(3) SoftMAX Y

ReLU(

Z (1)

� �� �W (1)X )

Page 49: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

Soft

Max

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

W(2) Z(3) SoftMAX Y

ReLU(

Z (1)

� �� �W (1)X )� �� �

Z (2)

Page 50: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

Soft

Max

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

Z(3) SoftMAX Y

W (2) ReLU(

Z (1)

� �� �W (1)X )� �� �

Z (2)

Page 51: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

Soft

Max

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

Y = SoftMax(W (2) ReLU(

Z (1)

� �� �W (1)X )� �� �

Z (2)

)

Page 52: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

In summary

Page 53: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Neural network for the iris data

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

Soft

Max

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

Y = f (X ) = SoftMax(W (2)ReLU(W (1)X ))

Page 54: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Forward propagation

In forward propagation, we go from X to Y by applying a seriesof functional transformations :

Y = SoftMax(W (2)ReLU(W (1)X ))

Page 55: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Forward propagation

In forward propagation, we go from X to Y by applying a seriesof functional transformations :

Y = SoftMax(W (2)ReLU(W (1)X ))

Questions:

How do we determine the weights W (1) and W (2) ?

Page 56: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Forward propagation

In forward propagation, we go from X to Y by applying a seriesof functional transformations :

Y = SoftMax(W (2)ReLU(W (1)X ))

Questions:

How do we determine the weights W (1) and W (2) ?

Why do we need the activation function ReLU ?

Page 57: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Forward propagation

In forward propagation, we go from X to Y by applying a seriesof functional transformations :

Y = SoftMax(W (2)ReLU(W (1)X ))

Questions:

How do we determine the weights W (1) and W (2) ?

Why do we need the activation function ReLU ?

Why do we use the SoftMax function at the end ?

Page 58: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

How do we determine

the weight values ?

Page 59: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

We want to choose the weights to make

the best predictions possible

Page 60: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

We will use an algorithm

to find these weights

Page 61: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

This algorithm needs

some initial weight values

Page 62: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

How do we choose

the initial weight values ?

Page 63: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

The naive choice

Page 64: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

We set all the weights to zero

Page 65: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

All the predictions are the same:

P=1/3 for the three species

Page 66: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

The weights are updated by the same amount

and thus cannot get unequal values

Page 67: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

The network cannot learn

Page 68: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

A good choice

Page 69: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

Random initialisation around 0

Page 70: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

We choose the weights according to

a normal distribution N (0, σ2)

Page 71: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

We choose the weights according to

a normal distribution N (0, σ2)

The value of σ2 affects the performance

(speed and accuracy)

Page 72: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

Two common choices

σ2 =1

Nin(Xavier)

σ2 =2

Nin + Nout(Glorot & Bengio)

Nin = the number of nodes going in the weight matrix W

Nout = the number of nodes going out the weight matrix W

Page 73: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

Probabilistic framework

Linear model:

Y = W X

Yi =

Nin�

j=1

Wij Xj , i = 1, . . . ,Nout

Assumptions: Xj ∼ N (0,σ2x ) and Wij ∼ N (0,σ2)

The condition V (Yi) = V (Xj) leads to the values for σ2:Xavier and Glorot (when including backpropagation)

Page 74: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

EXAMPLE

x1

x2

x3

x4

Input Layer Hidden Layer

z(1)2

z(1)3

z(1)4

z(1)5

z(1)1

w(1)11

w(1)54

Page 75: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

EXAMPLE

x1

x2

x3

x4

Input Layer Hidden Layer

z(1)2

z(1)3

z(1)4

z(1)5

z(1)1

w(1)11

w(1)54

Nin = 4

Nout = 5

Page 76: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Weight matrices

EXAMPLE

x1

x2

x3

x4

Input Layer Hidden Layer

z(1)2

z(1)3

z(1)4

z(1)5

z(1)1

w(1)11

w(1)54

Nin = 4

Nout = 5

Page 77: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

STEP 1

Y = SoftMax(W (2)ReLU(W (1)X ))

Page 78: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

STEP 1

Y = SoftMax(W (2)ReLU(W (1)X ))

Sepal length Sepal width Petal length Petal width Species

5.1 3.5 1.4 0.2 setosa

7.0 3.2 4.7 1.4 versicolor

6.3 3.3 6.0 2.5 virginica

input output

Page 79: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

STEP 1

Y = SoftMax(W (2)ReLU(W (1)X ))

Matrix multiplication (σ = 0.5):

W (1) X =

0.5 0.1 −0.2 −0.4−0.4 1.0 0.5 1.0−0.2 −0.2 −0.5 −0.10.2 0.7 0.3 0.20.6 0.6 0.1 −0.4

5.13.51.40.2

=

5.42.22.9−1.7−2.4

Page 80: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Activation function

Why do we need

the activation function ReLU ?

Page 81: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Activation function

A neural network without any non-linear activation functionwould simply be a linear regression model

Page 82: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Activation function

A neural network without any non-linear activation functionwould simply be a linear regression model

There are several possible non-linear activation functions:

Page 83: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Activation function

A neural network without any non-linear activation functionwould simply be a linear regression model

There are several possible non-linear activation functions:

ReLU is very simple and very popular in deep neural networks

Page 84: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

STEP 2

Y = SoftMax(W (2)ReLU(W (1)X ))

Page 85: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

STEP 2

Y = SoftMax(W (2)ReLU(W (1)X ))

Activation function (ReLU):

ReLU(W (1) X ) = ReLU(

5.42.22.9−1.7−2.4

) =

5.42.22.900

Page 86: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

STEP 3

Y = SoftMax(W (2)ReLU(W (1)X ))

Page 87: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

STEP 3

Y = SoftMax(W (2)ReLU(W (1)X ))

Matrix multiplication (σ = 0.5):

W (2)ReLU(W (1)X ) =

0.6 0.1 0.9 −0.2 −0.50.3 −0.3 0.3 −0.9 −0.90.3 0.2 0.4 −1.0 0.6

5.42.22.900

=

1.90.32.9

Page 88: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

SoftMax function

Why do we use the

SoftMax function ?

Page 89: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

SoftMax function

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

Soft

Max

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

Page 90: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

SoftMax function

x1

x2

x3

x4

Input Layer Output LayerHidden Layer

z(1) y1

y2

y3

2

z(1)3

z(1)4

z(1)5

z(1)1

z(2)2

z(2)3

z(2)4

z(2)5

z(2)1

z(3)2

z(3)3

z(3)1

Soft

Max

w(1)11

w(1)54

w(2)11

w(2)35

Sepal LengthProb. Setosa

Sepal Width

Petal Length

Petal Width

Prob. Versicolor

Prob. Virginica

Weights WeightsActivationFunction

The output Z (3) are arbitrary real values and we want to convertthem into probabilities:

SoftMax(Z (3))i =ez(3)

i

ez(3)1 + ez(3)

2 + ez(3)3

= Prob. Class i ∈ (0, 1)

Page 91: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

SoftMax function

Binary classification

Page 92: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

SoftMax function

Page 93: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

SoftMax function

Binary classification:

Empirical observation - logistic regression:

Motivate - sigmoid function (1 output neuron):

wikipedia

Page 94: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

SoftMax function

Binary classification:

Empirical observation - logistic regression:

Motivate - sigmoid function (1 output neuron):

wikipedia

Multinomial logistic regression: SoftMax function (K classes):

P(X )� =eβ�X

�Kk=1 eβk X

SoftMax(X )� =eX�

�Kk=1 eXk

Page 95: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

STEP 4

Y = SoftMax(W (2)ReLU(W (1)X ))

Page 96: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

STEP 4

Y = SoftMax(W (2)ReLU(W (1)X ))

SoftMax function:

SoftMax(W (2)ReLU(W (1)X )) = SoftMax(

1.90.32.9

) =

0.250.050.70

Page 97: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

STEP 4

Y = SoftMax(W (2)ReLU(W (1)X ))

SoftMax function:

SoftMax(W (2)ReLU(W (1)X )) = SoftMax(

1.90.32.9

) =

0.250.050.70

Page 98: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

STEP 4

Y = SoftMax(W (2)ReLU(W (1)X ))

SoftMax function:

SoftMax(W (2)ReLU(W (1)X )) = SoftMax(

1.90.32.9

) =

0.250.050.70

Prediction: Virginica

Page 99: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

STEP 4

Y = SoftMax(W (2)ReLU(W (1)X ))

SoftMax function:

SoftMax(W (2)ReLU(W (1)X )) = SoftMax(

1.90.32.9

) =

0.250.050.70

Prediction: Virginica This is wrong! It is Setosa

Page 100: Statistical methods for big data in life sciences and ...€¦ · Statistical methods for big data in life sciences and health with R Philippe Jacquet Data Scientist at CADMOS June

Network training using gradient descent

What to do when

the prediction is wrong ?