neural networks and genetic algorithms - cross entropy: machine learning...

19
Neural Networks and Genetic Algorithms [email protected] 2017-03-16

Upload: others

Post on 27-May-2020

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Neural Networksand

Genetic [email protected]

2017-03-16

Page 2: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Course Outline

1. Introduction to Statistical Learning

2. Linear Regression

3. Classification

4. Resampling Methods

5. Linear Model Selection and Regularization

6. Moving Beyond Linearity

7. Tree-Based Methods

8. Support Vector Machines

9. Unsupervised Learning

10.Neural Networks and Genetic Algorithms

Page 3: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Agenda

• Machine Learning Tribes

• Neural Networks

• Genetic Algorithms

• Naïve Bayes

• Wrap Up

Page 4: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

The Five Tribes of Machine Learning

From Pedro Domingos’ The Master Algorithm: How the Quest for the Ultimate Learning Machine Will Remake Our World

Machine Learning Paradigms

Page 5: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Example Function Approximation Network

http://hagan.okstate.edu/NNDesign.pdf

logsig(x) = 1 / (1 + exp(-x))

purelin(x) = x

Neural Network Example

Page 6: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Example: Initial Weights and Training Example

Suppose …

• we’re trying to learn 𝑓 𝑝 = 1 + sin 0.25 ∗ 𝜋 ∗ 𝑝 for𝑝 ∈ −2,2

• we’ve initialized our weights as follows

• we’re given the following input

• and the following output

f(1) = 1.707

Neural Network Example

Page 7: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Example: Forward Propagation of Activations

Neural Network Example

Page 8: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Example: Back Propagation of Error

Neural Network Example: Output Layer Update

Page 9: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Example: Back Propagation of Error

Neural Network Example: Hidden Layer Update

Page 10: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

The Gradient of the Logistic Function

2 2

2 2 2

2

1 exp( ) 1 exp( )1

1 exp( ) 1 exp( ) 1 exp( )

0 exp( ) exp( ) exp( )

1 exp( ) 1 exp( ) 1 exp( )

exp( ) 1 exp( )

1 exp( ) 1 exp( )1 exp( )

d d dx x

d dx dx dxdx x x x

d d dx x x x x x

dx dx dx

x x x

x x

x xx

1 exp( ) / exp( )

1 exp( ) 1 / exp( ) exp( ) / exp( )

1 1 1 11

1 exp( ) exp( ) 1 1 exp( ) 1 exp( )

x x

x x x x

x x x x

Neural Network Example: Derivation of Gradient

Page 11: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Did We Learn Anything?

Yes!

Our new output (0.759) is closer to 1.707 than our old output (0.446)

Neural Network Example

Page 12: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Choices for Neural Networks

• How many layers to use?

• How many neurons (activation functions) per layer?

• Which activation functions to use?

• How to connect neurons of one layer to the next?

Neural Network Example

Page 13: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Using Dropout to Prevent Overfitting

Neural Network Example

Page 14: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Example Genetic Algorithm for Feature SelectionRandomly generate an initial population of chromosomes

repeat:

for each chromosome do

Tune and train a model and compute each chromosome's fitness

end

for each reproduction 1 … P/2 do

Select 2 chromosomes based on fitness

Crossover: randomly select a locus and exchange genes on either side of locus

(head of one chromosome applied to tail of the other and vice versa)

to produce 2 child chromosomes with mixed genes

Mutate the child chromosomes with probability pm

end

until stopping criterion are met

http://appliedpredictivemodeling.com/Genetic Algorithm Example

Page 15: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

The Naïve Bayes Model

Posterior = Prior * Likelihood / Evidence

This model is called “naïve” because it assumes conditional independence to derive the likelihood estimates:

1

1 1

* |

|

* | * |

p

jj

p p

j jj j

prob class c prob x class c

prob class c x

prob class c prob x class c prob class c prob x class c

Add a small weight to the observed frequencycounts for all possible values: this amounts toincorporating a Bayesian prior to avoid thecertainty of zero or one (use 1 for Laplacesmoothing)

1 1, 2 2 | 1 1 | * 2 2 |prob feature value feature value class c prob feature value class c prob feature value class c

Naïve Bayes Example

Page 16: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Libraries

• library(akima)

• library(boot)

• library(car)

• library(class)

• library(e1071)

• library(gam)

• library(gbm)

• library(glmnet)

• library(ISLR)

• library(leaps)

• library(MASS)

• library(pls)

• library(randomForest)

• library(ROCR)

• library(splines)

• library(tree)

• library(caret)

• library(mxnet)

• library(xgboost)

Recap

Page 17: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Model Construction Commands (from book)

• lm()

• glm()

• knn()

• lda()

• qda()

• cv.glm()

• regsubsets()

• glmnet()

• cv.glmnet()

• pcr()

• plsr()

• smooth.spline()

• loess()

• gam(): poly(), bs(), ns(), s(), lo()

• tree()

• cv.tree()

• randomForest()

• gbm()

• svm()

• prcomp()

• kmeans()

• hclust()

http://www-bcf.usc.edu/~gareth/ISL/All%20Labs.txt

Recap

Page 18: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Final Notes

• For model selection: never evaluate a model on the data used for training the model

• The train() method from library(caret) is convenient for model selection

• Remember that small data means large uncertainty: use repeated cross validation for smaller data sets

• Consider evaluating stacking/blending to boost your performance

• Review: A Few Useful Things to Know About Machine Learning

http://homes.cs.washington.edu/~pedrod/papers/cacm12.pdf

• Keep an open mind: new methods/tools are always being developed

Recap

Page 19: Neural Networks and Genetic Algorithms - Cross Entropy: Machine Learning …cross-entropy.net/ML210/Neural_Networks_and_Genetic... · 2017-03-14 · Neural Networks and Genetic Algorithms

Survey

•Please help support my boss learning about me learning about you learning about machine learning ☺ [please fill out the survey]

•Best Wishes for Your New Adventures!