optimization methods morten nielsen department of systems biology, dtu iib-intech, unsam, argentina
DESCRIPTION
*Adapted from slides by Chen Kaeasar, Ben-Gurion University The path to the closest local minimum = local minimization MinimizationTRANSCRIPT
![Page 1: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/1.jpg)
Optimization methods
Morten NielsenDepartment of Systems biology,
DTUIIB-INTECH, UNSAM, Argentina
![Page 2: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/2.jpg)
*Adapted from slides by Chen Kaeasar, Ben-Gurion University
The path to the closest local minimum = local minimization
Minimization
![Page 3: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/3.jpg)
*Adapted from slides by Chen Kaeasar, Ben-Gurion University
The path to the closest local minimum = local minimization
Minimization
![Page 4: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/4.jpg)
The path to the global minimum
*Adapted from slides by Chen Kaeasar, Ben-Gurion University
Minimization
![Page 5: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/5.jpg)
Outline
• Optimization procedures – Gradient descent– Monte Carlo
• Overfitting – cross-validation
• Method evaluation
![Page 6: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/6.jpg)
Linear methods. Error estimate
I1 I2
w1 w2
Linear function
o
![Page 7: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/7.jpg)
Gradient descent (from wekipedia)
Gradient descent is based on the observation that if the real-valued function F(x) is defined and differentiable in a neighborhood of a point a, then F(x) decreases fastest if one goes from a in the direction of the negative gradient of F at a. It follows that, if
for > 0 a small enough number, then F(b)<F(a)
![Page 8: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/8.jpg)
Gradient descent (example)
![Page 9: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/9.jpg)
Gradient descent
![Page 10: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/10.jpg)
Gradient descent
Weights are changed in the opposite direction of the gradient of the error
![Page 11: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/11.jpg)
Gradient descent (Linear function)
Weights are changed in the opposite direction of the gradient of the error
I1 I2
w1 w2
Linear function
o
![Page 12: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/12.jpg)
Gradient descent
Weights are changed in the opposite direction of the gradient of the error
I1 I2
w1 w2
Linear function
o
![Page 13: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/13.jpg)
Gradient descent. Example
Weights are changed in the opposite direction of the gradient of the error
I1 I2
w1 w2
Linear function
o
![Page 14: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/14.jpg)
Gradient descent. Example
Weights are changed in the opposite direction of the gradient of the error
I1 I2
w1 w2
Linear function
o
![Page 15: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/15.jpg)
Gradient descent. Doing it your selfWeights are changed in the opposite direction of the gradient of the error
1 0
W1=0.1 W2=0.1
Linear function
o
What are the weights after 2 forward (calculate predictions) and backward (update weights) iterations with the given input, and has the error decrease (use =0.1, and t=1)?
![Page 16: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/16.jpg)
Fill out the table
itr W1 W2 O
0 0.1 0.1
1
2
What are the weights after 2 forward/backward iterations with the given input, and has the error decrease (use =0.1, t=1)?
1 0
W1=0.1 W2=0.1
Linear function
o
![Page 17: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/17.jpg)
Fill out the table
itr W1 W2 O
0 0.1 0.1 0.1
1 0.19 0.1 0.19
2 0.27 0.1 0.27
What are the weights after 2 forward/backward iterations with the given input, and has the error decrease (use =0.1, t=1)?
1 0
W1=0.1 W2=0.1
Linear function
o
![Page 18: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/18.jpg)
Monte Carlo
Because of their reliance on repeated computation of random or pseudo-random numbers, Monte Carlo methods are most suited to calculation by a computer. Monte Carlo methods tend to be used when it is unfeasible or impossible to compute an exact result with a deterministic algorithmOr when you are too stupid to do the math yourself?
![Page 19: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/19.jpg)
Example: Estimating Π by Independent
Monte-Carlo SamplesSuppose we throw darts randomly (and uniformly) at the square:
Algorithm:For i=[1..ntrials] x = (random# in [0..r]) y = (random# in [0..r]) distance = sqrt (x^2 + y^2) if distance ≤ r hits++EndOutput:
Adapted from course slides by Craig Douglas
http://www.chem.unl.edu/zeng/joy/mclab/mcintro.html
![Page 20: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/20.jpg)
Estimating P
![Page 21: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/21.jpg)
Monte Carlo (Minimization)
dE<0dE>0
![Page 22: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/22.jpg)
The Traveling Salesman
Adapted from www.mpp.mpg.de/~caldwell/ss11/ExtraTS.pdf
![Page 23: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/23.jpg)
Adapted from www.mpp.mpg.de/~caldwell/ss11/ExtraTS.pdf
![Page 24: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/24.jpg)
Adapted from www.mpp.mpg.de/~caldwell/ss11/ExtraTS.pdf
![Page 25: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/25.jpg)
Adapted from www.mpp.mpg.de/~caldwell/ss11/ExtraTS.pdf
![Page 26: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/26.jpg)
Adapted from www.mpp.mpg.de/~caldwell/ss11/ExtraTS.pdf
![Page 27: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/27.jpg)
![Page 28: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/28.jpg)
Adapted from www.mpp.mpg.de/~caldwell/ss11/ExtraTS.pdf
![Page 29: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/29.jpg)
Gibbs sampler. Monte Carlo simulations RFFGGDRGAPKRGYLDPLIRGLLARPAKLQVKPGQPPRLLIYDASNRATGIPA GSLFVYNITTNKYKAFLDKQ SALLSSDITASVNCAK GFKGEQGPKGEPDVFKELKVHHANENI SRYWAIRTRSGGITYSTNEIDLQLSQEDGQTIE
RFFGGDRGAPKRGYLDPLIRGLLARPAKLQVKPGQPPRLLIYDASNRATGIPAGSLFVYNITTNKYKAFLDKQ SALLSSDITASVNCAK GFKGEQGPKGEPDVFKELKVHHANENI SRYWAIRTRSGGITYSTNEIDLQLSQEDGQTIE
E1 = 5.4 E2 = 5.7
E2 = 5.2
dE>0; Paccept =1
dE<0; 0 < Paccept < 1
Note the sign. Maximization
![Page 30: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/30.jpg)
Monte Carlo Temperature
• What is the Monte Carlo temperature?
• Say dE=-0.2, T=1
• T=0.001
![Page 31: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/31.jpg)
MC minimization
![Page 32: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/32.jpg)
Monte Carlo - Examples
• Why a temperature?
![Page 33: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/33.jpg)
Local minima
![Page 34: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/34.jpg)
Stabilization matrix method
![Page 35: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/35.jpg)
• A prediction method contains a very large set of parameters
– A matrix for predicting binding for 9meric peptides has 9x20=180 weights
• Over fitting is a problem
Data driven method training
yearsTe
mpe
rature
![Page 36: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/36.jpg)
Regression methods. The mathematics
y = ax + b2 parameter model
Good description, poor fit
y = ax6+bx5+cx4+dx3+ex2+fx+g
7 parameter modelPoor description, good fit
![Page 37: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/37.jpg)
Model over-fitting
![Page 38: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/38.jpg)
Stabilization matrix method (Ridge regression). The mathematics
y = ax + b2 parameter model
Good description, poor fit
y = ax6+bx5+cx4+dx3+ex2+fx+g
7 parameter modelPoor description, good fit
![Page 39: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/39.jpg)
SMM training
Evaluate on 600 MHC:peptide binding dataL=0: PCC=0.70L=0.1 PCC = 0.78
![Page 40: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/40.jpg)
Stabilization matrix method.The analytic solution
Each peptide is represented as 9*20 number (180)H is a stack of such vectors of 180 valuest is the target value (the measured binding)l is a parameter introduced to suppress the effect of noise in the experimental data and lower the effect of overfitting
![Page 41: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/41.jpg)
SMM - Stabilization matrix method
I1 I2
w1 w2
Linear function
o
Sum over weights
Sum over data points
![Page 42: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/42.jpg)
SMM - Stabilization matrix method
I1 I2
w1 w2
Linear function
o
Per target error:
Global error:
Sum over weights
Sum over data points
![Page 43: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/43.jpg)
SMM - Stabilization matrix methodDo it yourself
I1 I2
w1 w2
Linear function
o
l per target
![Page 44: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/44.jpg)
SMM - Stabilization matrix method
I1 I2
w1 w2
Linear function
o
l per target
![Page 45: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/45.jpg)
SMM - Stabilization matrix method
I1 I2
w1 w2
Linear function
o
![Page 46: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/46.jpg)
SMM - Stabilization matrix methodMonte Carlo
I1 I2
w1 w2
Linear function
o
Global:
• Make random change to weights
• Calculate change in “global” error
• Update weights if MC move is accepted Note difference between MC
and GD in the use of “global” versus “per target” error
![Page 47: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/47.jpg)
Training/evaluation procedure• Define method• Select data• Deal with data redundancy
– In method (sequence weighting)– In data (Hobohm)
• Deal with over-fitting either– in method (SMM regulation term) or– in training (stop fitting on test set
performance)• Evaluate method using cross-validation
![Page 48: Optimization methods Morten Nielsen Department of Systems biology, DTU IIB-INTECH, UNSAM, Argentina](https://reader035.vdocuments.us/reader035/viewer/2022062413/5a4d1b527f8b9ab0599a81c7/html5/thumbnails/48.jpg)
A small doit script//home/user1/bin/doit_ex
#! /bin/tcsh foreach a ( `cat allelefile` )mkdir -p $cd $aforeach l ( 0 1 2.5 5 10 20 30 )mkdir -p l.$lcd l.$lforeach n ( 0 1 2 3 4 )smm -nc 500 -l $l train.$n > mat.$npep2score -mat mat.$n eval.$n > eval.$n.predendecho $a $l `cat eval.?.pred | grep -v "#" | gawk '{print $2,$3}' | xycorr`cd ..endcd ..end