Machine Learning Handwritten Notes
Machine Learning Handwritten Notes
[Link]
•• Join me on LinkedIn for the latest updates on ML:
[Link]
•• Download Machine Learning:
[Link]
•• Join me on LinkedIn for the latest updates on ML:
[Link]
•• Download Machine Learning:
[Link]
•• Download Machine Learning:
[Link]
•• Join me on LinkedIn for the latest updates on ML:
[Link]
•• Download Machine Learning:
[Link]
•• Join me on LinkedIn for the latest updates on ML:
[Link]
equlanizaton
,
ovcs{it. A way to avold oves{4Aing data
especially o models (tke tineas segcessfons
hat a&e haviluy atkeoted by outiess we can
USe &egulaxizaion Tbis wi ead tota mose
N9eneSamodel that is technicall
less accusae
bt geoecaliges to he data betes.
. Kidge12 BeasesS
used to cedúce oveHHi ng)
E
Cost unclion= O
Testtng data:low/bigh
VOianceY
costPuncHon:
2
cost uncion
hec-
m i
A(slope
beCo)
muliple
. Bo+ein>>
keaturcs
hypex
slopc= 611
aepeeSent, then
paxamete
(slope )=2(slope
20
-02 o 06 o8
sbittinq tousards 2ero global minima
slope
inveksly pcapaSHonal.
A =4 make swe +hat ou line'doesdt
OvCit.
O
the
is
lage, the
OSbinkage.
a
The cockhecieot
compleocity
amount o shinkage *
Value o ,
poMameee hat
he gseate
arc sh<unk towayds aero.
controls 4he
the amount
L RequlariaatHon NOSm)
+is used to &educe the leatwres belps in
Leature Selec4ion
CostuncHon
TCe 30
-20
0 t
-02 O o2 0.4 06 o 8 .2
be() -6o+ 61o+O2o2 +9303
o+0.S40 +0:23d2+o 103
leastcONElaed
data has ouHiers use Ridge Reg&ession.
Elastc et
combinaton ot LI and l2 Regularigalion:
cost uncHon
= he(x)-) a (slope)2
L2
21slope
Siae - o75%uweight
weignt>
-inecept slope
Inothee
o
uwo ds, we initodace
BiaS intohoshe neo line ts
but in etuwen fos ha
o
+
small amount
to the data
smal1 omount ot bias,
we get a signi Rcant dkop in vaniance.
lambda.
his poet adds a penay to
iao the aditional least squake
method.
and lambda (A) dede oines how sevexethat
penalty îs.
etaht
Sige
he paedetion
tn wetaht
One unit
w
fos sige boely
nu
eNt2or
1
indeases
0,]Ridge =
Awhen
RR
&egtession line
ended up wih
he leoaSt
leastsquare
a smallee slopehan
squoRe line
ine
co6s esponds
O
nAer cep C
o 9
40heaverogesige0Smal 8
he mice on 4he
diet
sum ok +[Link]
is he peedioion fot ahe
(slop2
+
+dietdistance)
le ast squaxes cant ftnd a slng leopmal
Soluton, Since any ine line Ahat qoeswoug
4he dot wil minimige Ahe sumof+he
squaxed sesidaals.
ummaku
henthe sample sizes ate elatvely Small,
hen RR can impfove pfedictions made feom
nes data (iie. educe vaeiance by making
Ahe péedictions less sensive do the
[Link].
Ivarlable Ivaniablenl
(vaeiable) a. +(yaiablen
ote
E
LRand fRR penalty aet thei& ouon As
datoset:
Study bous Play hOtUMS o/PCPass/ Fail)
2 Fail
3 fail
3 PasS
OutlieS 1 Pass
6 8 10 12 13 14
Fail (Butin Seality itis fass)
ohy we use loqisic Reg&cssion when we can
Solve alassipicaios psoblem using
Linea Regaession
and
due to outliers best it line gets change
6esults wi be wsong
Squash("cut")
best tline using sigmoid
AnctHon.
he(ox)=Go+61
best ktlinc
Squash "cut")(
using Sigmoid
o uncHon.
hex)=6o+610
Sigmod kuncion > output wil
&ange betn 0 and l.
SCeo,6)
heco
MSE
heox)=eo+01
GH&adient desent
Conveo kunction
one qlobal minima)
Steps:
Cfeaie best itline
apply squashing3 using siqmoid unclion
S(e0,e1) = he o)
sigmoid uncion
he(o) s(e0+e1)
et tihaicniMAaABot
Aet Oo+e10
heC)= (R)
hec)
be()
1+ ot81)
be()=
e0+610()
e No convea
unction
e
change theCost unchon to solve thè convexity
p&oblenm
1oq he(x)
cost uncion
conveacunclion
he (a) =E
+ ®o+61)
Cost (he(o),
minima
1og(be))
)1og(1-ha(a))
valuc
reath
minimige cost uncion (€6,e1)
by changtmg
e0, 61
Convetgence Algosithm
Repeat Convegence
J
3(eo, G)
o O andjal
take hscshold =0:5
by dekault
using ROC ond ToC CUxv€, we can
deine+h&eshold.
Conusion matviot
2 Acc acy
3. Pecision
Reca
5. P-Beta Scoe
datase*
Olp P-y(nodelpfedictE
co8Eect
Oweong
peediction
pfediction
3 2
pfedic+ed O
value (G)
Actua value
TP Tue Posittve
TP FP Co6sect
TN: TEue Megakve
match
TO
AOL us&ong FP: False Positive
Accwxacy
reis
AccwKacy TP+TN
TP+ PP +FN+T
lcoo datapointHs
oo Imbalanced daaset
(o)
Psecision
Peecision TP
Actual TP+ PP
Diabe4es o ot diabees
Actual diabeles and Psedicied- Not
diabetes
Ceittca p8oblem Seduce PN
Recall
Oat o 'ai 4hepfedicted values
Recall TPTP+FO
howmany aURE cwKAentY
Psedicted.
Companies RP
(can Aake cextain
decision)
-Beta Scose
[Link]
+ Recall
O FP and FN oke both impostant
PI Scose =[Link]
P+R
PP is mose impostant
B 0:5
han P1o
3 1 F >>FP, (FPis
B2
less impo stant 4han Fru),
F2scose = (+4)PxR
4x P+R
Clasalea
Classikicaion_psoblem, it just /kethe
eOhleM ECept hat the values
a
ake on oni small numbef o e
Segsessionadel
nooUOant topdedict
discsele Nalues
yEO,1 O Ve class
Binaey class 1 +Ve elagS
Hypohesis Kepseserstatio
iu iively
ages %an o
,
it doesh't omake seDselo8
0
smalles thao obeo we
be(ox)totakeNalues
be (o) g(eox)
ga)
funetioo q*), shocmD besc,
mapsanydea oumbee8 tothbe
0,1) iotesval, making
it usekul o6
4eansfosmingan
Obita6y-Nalued tunetioninto uncion a betteašuited
{o classiticatio
beCo) PCye1|xe)=
PCyolxie) +PCy»|lx;0)
Oecisioo Rounda&y
be(ox) O:5
beot)o: 0
Tbe way ousogistickuocior g
behaves is %at uben ds
inpu is gseavefhan of equal to 3e€0,its outpt is
9EcateS hao o6 equal 40 05
>o:5 when2>0
Remembes:
0,eIg /2 Cor)=
o, e 0g()
g(o)0
SoioEinput 40 is e heo +hat means
Tbe decision
afea usbe
se
bypobesis uncion
o
boundas tsthe line
ql + +[Link]
CSeated by ou&
*e
papergrid
Date:
Yi 5+-)X+0.270
5- O
153
o his Cgse Ou6 decision boundoafy tsa stsaiqbt
yectical ine_placcd on thegsapbwhes =8 add
evesyh{ng *o he lef q{ that denotes wbie
evefyhing fothe sigbt depotes q0.
again,he înpit to
eed o 6esiomoid functioo
6e tineaf, could be atunctioo
g)
ot
[Link]
a
desesibes
doesot
Cost RuncHon
S(O) m i1 cost(he ( y)
cost (he(oxt),u)=-Hog (be(od)iya
cost (he (oc)) -loq-he(0 ity=o
ngto) heta)
papergrid
Date:
=0
cost (beCo)1y) ba)E
ye0 and beo)->1
cos+(beo)1)0,i
COS (he(atd,y) ie and be(c)->o
Gadient Desccot:
RepeatR
Repeat
\.o
halo)-yi
mi1
2
Notice
tnlioea
updaie
Segsessio0:
al
e
hat hisalgos ithm is idenical to he one awe used
St have do simulta0eously
valuesin the1o. he)
isdittesent
e - x(a(xe)-
Advanceod Oplimalfon
GSadient [Link]
desceo
Goojugae gsadient
RGS
LBRGIS.
Mollclasg_elassiLcaions
be) P(y:olgx;)
ha(o)= PCyzilox;e
he'(ox)=_PCyzolx;6
pSediction ma«ha (ox)
wea&c basically
lumpiog a he
one class andhen
choosi0g
othess into o single 5econdclass, uwe dothis &epeated
papergrid
luio9 6i0as Date: I
logisic
usehe egeessiontoeach
bypothesis
Asedietiog.
hat case,aod *6us
ekusned thie btghest
NalueaSOu
ne-Vs-alone-vs-eal)
AA-
o
-
Class
class2
class 3:x
:
A
heloc)=P(y=ilx;e) Ci=2,3)
To summasige
Tsain a logistic segsession class ikiee helo«)jo8 each
a
OD new input ox,to make a p$ediokion piok the class
hat m acimizes
mao be()
KequlaiQatM
De+A
Reduccheoumbec
of_{eauces:
manuglly selec¥ wbich {eotues
do keep
use a
model selechon
algoeitbro
2. Requlacization
keep al thejeaukes
O
,butseduce
pasa meieks 6
heoag oitude
Regulaization wasks wellgobeg
lot o slighkly usekul uebavea
[Link].
oe 6oveoverHA0g
{om
can seduce the uweiqht ou,byupohesis
that someok he fungkon1
eams inOudG
papergrid
Date: I
doithout elinminale
actually
geHing eio o fhese featues
changing *beofm ofcut
oue cOSt unchon. bypdthesis, C oe
COn iosfeod modig
mine
2m 2
2 (hao)-yi +1000 e+looo.e
Now io08de& {08be cost_LuncHo0 toget
closett0 2ek0
we oil bave to eoluce be valueS O O3 and
toneot
This uwil in dun gseatlySeduce the
in
ReYO
N
oue bupothesis ungio0
Nalues okSZA
i/
6i3e House ,Sige qf House
0o+1x+62t
mi6 1 (ba(i)-qi*+
2
10vo2 lovoet
ta parom.
all Oou heYa paamele
CouCould alsoSegulaeige
i a single sunmaions aS
mio belori)-yi+2J
e 2 il
lambdo t
is choosen to be too laxge, may smooth out
he luockoo doo much and cause undeAiing.
Gsadieot Descent
we wil1 g8adient descent {uocion to sepogYe
moodify
out Go_16om he
Sesf O hc_poramcYers because do we
o0t wan to AeOalize eo.
Repeat
o Go-X. 2 (baoci)-qi.
j ba(od)-i\
iESh2,s
papergrid
1
Date:
S
sanipulaton OUG update sule ca0also be sepsesenled
mi
aluays willbeless ¥haD
Nosmal Bquokoni
1
down the
Lisam aeio with O atthe topleftt and ps
evesywhcse else
diagonal, with O's
I XP*).
shold hove dimension(nt)
intuitivelu ,
this is
Howevel,when we add
Imx, 4hen X 'Xis non-OVeSH6le
hen X'X+*L 6ecomes invesihle.
the deem A:L
papergrid
Date:
ion
Keqularigeod oqistte Keqkess
CoStuno¥ioo
GOS uOCion {OSlogishc
Segsession GS
laq(1-8bec
SO)=[Link](ha(ox))+(q).
20 je
Grsadieot Ocscent
Sepeat
o eo-o:
M, (baC)-yi).
- i alg
ei heCcxi)-i)a+
ste) (12
uppant Vectorachine
CsYM)
* can solve both classiicationand Regsession
poblenm.
2 Regsession SVR (
Suppoct Nectos
Regsesso6 )
Some basicsS
line
Equation of
mo+C OR
Bo+Bi OR
aNtby +C 0
a coekkicient
-C
a +bo2+C 0 2 Xb/
Iniercept
'+b-O
line passes h&ouqh
Oiqin wTo =6
matria multiplicahorp
U02
Cw b0 (uo w T6ansposco)
P.c
ahgle g0° wehave +oLnd the
distance distance O} point
TCplane
eom he plane
distance
ine
2) and in20
angle 90°
P plane in 3D)
,
11
co11
11w11.11P11 cose
d 32+42
25
3
d
Cwheevectos, d= d
(11d maanitude
315,4ls) C3r5(415 s1os
unit vecto is a
way to get ocased on disection
bot on maqni fude
podvectoe
d wTP
d luwll:11P.l). cose
(-ve)
(+ve)
u E
E
point below heplane Pat2)E
6300
cose wil always bé t+ve'
maxaina plane
bestHt line
Suppo&+ Veco& manginas
points which axe plane
C&ossed by
maginal pane)
Equidistant
d should be maoxi mum
you can havemose than One Suppo@tvectoe
Ave
-Ve
sTotb ao'+b 0
w+bz+1
w'o+bE +1
fori
-s (-X2)
2fb:-1 2
d=distance should
1-2
w
be maximum 2
llwl
constaints> qi T+b)1
minimia
minimiae by cha
2
min 1ull
2 C Hinge loss
3o makqin.
o&
minimige oll
2
Ci
sb Hinqe loss
mAE
Etaoi
consitaint:yiwixis +Ei
Hyperparameter
keep adijusing E
+o qetbest mostgin
wecant say
imcosseat point in
Segsesso&.
w+b -E
1 pcdicted.
sige
2D
kennels
VM Kenels nean 5VC
SVmkernel
o4a
mea
Sepetable dat
inear Scperable data.
the dimension
Thisanslo&mation incteases
he daa. (mahemaical kasmala
:iesto
line
lincqe sepekable
>willgive eixo& :
ao2
Ae
Now, we can use lineam
Seperable line.
So
2-3
= =7 49
9 and soon:
1 Polynomia kerned
2. RBF kexne
Siamoid
3. kexnel
keene
2
olunomial
S0,we ne edto
ConveNt 20 3D.
Fig 3
Top vic ow
Owe ain aim waS to
înceasC dimcnsion
20 3B0
<
30, hypexplane is magina
CEeated Jplame
best
itlinc
Fomula
1a Jos Polynomial kcrnel Fia
C,)=( 2+1
d dimension
I
we axeconvekting 2030, hevalue of d3.
2
2|
2, 2
:.
2
:
3 unique valucs 2,
ow, iniiially
at the time o Fig 3 we have:3 caara
Heuu
we have 6
2
lcatweS cam be
1o6mewa
Jeatuwres
plotted
ob
as he30
a4: which means that
all
be
uoill
wilt be 22
(2 Radiad
Radia Basis Function Kexne (RBF Keenel)
-11-f
K(,)= e 22
hype paUramctet
Sigmold kexne
Hcan be used as he psooyo6 necueo
netO&ks.
k(o,) =tanb(6xxit
•• Download Machine Learning:
[Link]
•• Join me on LinkedIn for the latest updates on Machine
Learning: [Link]
•• Join me on LinkedIn for the latest updates on Machine
Learning: [Link]
•• Download Machine Learning:
[Link]
•• Download Machine Learning:
[Link]