Professional Documents
Culture Documents
After the successful completion of Fundamentals of Statistics , your pal Scooby is back with a
brand new set of handwritten lecture notes. I found that many of you liked them and appriciated the
work by thanking me personally on my email. Which by the way is :
(I do care, please message me. I was just pretending to be indifferent in the above line so that you
can't hurt me emotionally.) Anyways.
I tried to make these notes without any mistakes and cover most of the video material.
I however DO NOT TAKE any responsibilty if you fail your exams following my notes. So please
check the actual lecture slides and videos if you suspect something is wrong, and mail me too.
The notes DO NOT CONTAIN solutions to any homework problems or in-lecture exercises.
Only the problems and exercises solved in the videos are included in these notes.
MARIJUANA MONKEY
I ran out of made up quotes so I will write very short stories instead. These may or may not
resemble true events, but will definitely have a message that will help you along the journey, that is
life.
There was this dude named Chad. He chugged a lot of bear in parties. He was a trust fund kid. He
used to talk about generic s**t like , how much he could bench, or the game last night. Chad
frequently used to give life advice to people in his Instagram story, about living life to full, not
being afraid of anything, achieving their goals etc. He didn't care about fame, he cared about the
lives he touched. Atleast he caimed that.
There was this chick named Iris. Iris's father was a millionaire. She had self diaganosed herself with
depression in order to appear cool on her social media. She used to caption her pics with stuff like
'I am a mess, but I am a beautiful mess'. Obviously the pics were in grayscale tone. Cause she was
sad. Maybe she understood life really well.
Chad and Iris met at a rave party. And there were sparks all around. It was as if they understood
each other. It was love at first sight.
They talked about how to end world poverty and how the world would be a much better place, if
everyone was happy. They went on expensive vacations and were now the power couple that
infuenced people on Instagram. They talked about helping those in need, and took a selfie
everytime they helped someone. They dismissed their critics as haters, and lived happily ever after.
THE END
MORAL : No matter how screwed up you are, there's always someone equally screwed for you out
there. Go make this world a horrible place.
I,oe ove taLk[ng oboub aupeYvi*ec\ {eo.rninq- h"eve, , vshich" wteotil tv\re
wrLL how Labelted dqto" . (At least *'raivt. datd wtll be Lobelled)
{o eoch cqse $rov* *he trqiyl, data, hre NilL ha,,e q. J,abel ossoc(ated
& for eoch. co.se ttr, the test daba h!€. r-oovr,t tD predtct -tlae LabeL.
{or Lhe rvtovie example h)e ar€ studyin2' each r..ector couU hsrne o'ne
ot the *: to.l<',
(t )
: inclfcottng v(enry would watcVu it]r" movle
v _ : indicaH^a vfewey wo-utdn't rcatch i{n" rnowe
1
il. Agairu
{+s lh" *e\ "l zxomples ttot rue ieed our otgcrifrtvn in ordev 1o trairr.gnod
ovE dotng -suge vvised
Leorn i^t nylrulctu meqnA the tvaininq clotq 6,re
hor,e wttl be Labell ed. nd hlg l^tc tt ln-q\€, t4- exo rnples +o {eed
(ne.e,fore mathemattcol$ t,rle rnriLe
3n = t(^n,,J,t,), i=1,2,2,....n1
V gel eJ otl paivs ( feature lrector [ , tqbel t ) fo, o[ y1 €oses
z.z
) Clossif ier : l'u()
ltis ;trngty a functron o, ryppin3 {rm ?( ; [,e the sPace C fu.+"re raectur:
+o {lre spa.e laloeLs. 6v *he howe exomple h}e had
"l
L" , -R' F+ t-1,+1l
Itae idea wos ,strvrple
hxrL hnre jur,r,cuovt h( ) th,.t hltll *oke os in-put fny {eat.re rneclor
a
^)e oat a coTY€sPonding label +1 ot -1 ' lw srnclev to do
X anC Br'\^e ug "X
to tratn *he rnodel . lnis Juvrchon h( ) vrre 6orc
tl^at ,^re wtri ir.t rgeed
wttL irufacb depend ; payometer g (v'hreh con- rce rnutttdirnerrgionol) ,4n-d
uatng the broining dobo., hle wliLL esttmabe er's b {tnd on'optirrraL h( )
fne-^*^tftpredicb'labelst-.si;^?*lar'sogttmolh()'
)Tva[rn i Erro" gn ( h)
In ovdez to see hor,.r ourc clossi$ier pevfovmed r^rrt tvairuin2 dut& , nre needed
Aorvle sovt o{ rnettic , {he ideo hte l,-od rttos pr€+! -sirnple : f,ust Jooi(q,b
rnrhat fvactcon d polvtts tt,r" 4he 'traintvtg A ek afe rvr.r'sato,*r-fted by irt I
Ao we introduCed *he double bracket not-a*tcn't
+ Ne eon thevt comPoY€ -Lhese *rruo vo*Lues +o {*^d av\ eyrcrl. , xiwriliaz
bo outr 'lroivting EYYOT
m
6 (h) 1
f
fest tvror n1" [t(xtjr) * J'i,]
j=r
Now NoTE .thot *'his hli,ll ontg be posstble to caLculate nyluen t,rle hoyrg
acfucrt {obels for )he coseg ivr, U.re aesr Data sET, r"Ylarch nt^J nok
alrnloys be twe case
we sow 'that {fis mov€ cholces rde ol.tovued $ov h( ) , -the )et* generatrzed the
rnodeL becorne. 'le atlhou6ln hle got pel"fecb clo,s.r,iJrers 4w the tmin s,et wcg^,
tn(h)=0 ; {hey f"il€d nntsevabty when applied 1o tes+, dota,.
VG olso vevlse the Xeovwetvic i.h^* rue had iw wr.,n d t^ln i le doin6-
oll"'+hig
2.4
eornetn'c Prcture
ln, ordev lp ar.ralys€ "rha.U h-oppetned fqlrnelri"&V, uoe took
,LO r<..axis
\nle hare a *trat6ht li"l. above calLecl o xr axts . Arld t"re lto.ue Boryre poinb at xo
N0rat ts t*re equatton d +l"ir point !
ItraK a. vatlaer +iLLy luestton taut t$ r"rc 'l^"aue to oruroev it , *he equa*ccra,
wou[d be %4 x-o
=
Norttoke rndtat {l.r"ts potnt, ,tA doing ttrs divicling *iue X1 axis or tiyr.e
trnto two regtorrs . 4 fe
o. .tittte
Xr oxi,s Nor^c hle ?ro.ue trxo axes 2cr and xz
le rap hqw o 2d plarra
w€ also ?r.are a -[ivte it^.ad pal^es throgh
tnis plane
lr{e a6crtn ask 'the lues*toru, n*rat jL
aa axtS
be elua{/.on o/ +Lrfr Lile
2,e
9le axis h)e alvreody knotnl +hat *he equattorn, { o.
But rde o.2o.in waVe ct palteYrt irere {vr. P\r e lrne diwdeg *he 2d plane
ivrto tra:o tre g.iorus
?(1 oXlS
x x,Po ivtts abolne the }tvte
x o : points tcetow the li'te
o
x
Qood
yLot/lc tets rrao\€ or4 lD the next caae
a
# --- X2 axis aLvectdy knoro {hat *he equah'oa
oJ
a
plone t! oJ {orrYt
o)Lr * bxn* CXg = d
con again ree '[he.
.{nd v.r
D(t oxls potfevn con*tnued he're
2.7
Jine plone agatn diWdes *he 3d ,=#on into tr,oo Pot(K
:
Re6ia't 1 Abovre the Plane PoinK
Regron 2: Belor^r the Plone Points
9Cg axri
x: potnts o,loove the plane
*--
r'\ /l
\r/' xLaxrs
r'.)
o
o
l(r axrk o
visuallyr
) Ao nord \^)e cartt go ony {uv{ffev
Because -lheve/s rro Nay hle con dravo
a 4d plok' Bub nrecqn vuathemailcall)r
+roE le(s look ok the 1^)e
trqnsl.,oLe -Prts rdecr fovrcovd . EeJore dory ^tmiUaviLies
l.uod Jor otrr R exarnPles' obore
Equa*dorr, d
9C1 r xo = o
frtvtt tn ldirrrenstavrr: C =O
Ltne in zdimenrisnr: Xx-IflXr-
[w Exgtbxl+ cXt - c[ :- o
plone Zcltmenrtcnt:
9n
rrxl x rL nxt
Chen r^,e ccln use the doV grocluct ( eTx or O.x) {o urihe the
efuatton ,J hyper plane aE
Bo + g.X o
Novo +w )tt^t ,J *itis we^) {wrnutaL.r ., lets lcrkat otrz old examples
poiwtinld Z %t-2(o =o i t0o=O +
Or?tr Or=1 , go= -?Co
tine lrru 9.d i*t- hxr - e = O ;022t2+9rXr*Oo = O + 91=-trt, 0:-=1, Oo=-C
gtone [ra tsd
3x3*bxz+cxr -d=o )
glxl* O1eC2 *91etr+ 0o = o
'A|["rc'
o axts
herre, xz =o
*o 2(r=-e /et
o
b
9(1 a)<lS U v.)e f^d *he dok Pvoduct d
9 -l
ue'toz lrrgl'lln AB vtE, gek
( -0o rO
srl
Or ) In, Oo./9 r
0o -0o = O
_ g,/oz
o
r'j,"J=I
go/OrJ f-0o/er
o
a -l 1
:
CA o
=
t \ ,-r-n" ar) I s{e ,7
r J L-3,,,, \
Nor,onol6 g.A =O = B,d
\e,
9c1
Tneve-Io,e 9'i = o ie g wci6t' i3 putpendiculox
[o at{Y t'lne
wctDr ort P\one '
2. 1o
F os. oux dossrftev, nrhy dor{+_ r^}e ,^*u the l,r-etp o{ a f.,lk"pfarle
tn srder tp$Crst,fCnct out closstftei h C f ?
r{d h}e h}tlt [nde ed d o exactty .ttr,at , Ide rarill norc tackte the rnorrie v€cornrne-
-ndev problem r usin6 qprplanet L*lp in .f-or minq o cto,lriJrer.
-t Gr": nobe that a
hyperplo.ne is oetua\ 1-,rrt, a lwte, r^Je alce in
{ dtrnensiol.ral s ^rheyt
Pace
Xe dec{ded eorLr'ey +rc keeg *}ri ,sirnple, {trat
e f*"fu re \nector ^gA
foy ith rnor&: X(il hr-rll hore *raro {eefuves fq Xtil e &z
Ao our hyperplone will be a li4e in our exawrgle.
{he wtat*revraatfcql
$rntula*oru .t]rot nle uottl r,r*e or" cleyir e rarttt be
)tor,'relre,r
appricc''bte '{or cLnJ pvoblem ol
t^ro - ctqss ctorarJrcokon , u.{tiu a ganeraI
fe"ture wctor X e-Rd
v{e rnoy nob be obte +o vis\rotixe it nrhert d >3 but *lae. mdd^t*ztattcaL
ideas hrtll revnain,
the aome
divide the
fr1 plone
into hoo
reAi.or/ts
ustng a
ldne
*.1
x
9rrCr+ 9z%z = O
(r)
X
t g g
I
/ olr d.g
./<- *
-
;(a) t
)lr 1
I
x(2)
I
I
ua
x (+)
Here hle see {rco w c*oys that Jie arr.
Regton By deffi oJ do! procluct Here tnre Aee w,ctors ta.ob tre
*r,^lo on
Reg.{"orru By def 'n oJ dor product
0" x = ll e ll llxll Cos(L bw Jhe -t'",o) 0' X= ll9 ll ll x ll Cos ( 4 bro *he {r,oo)
o. x = llo ll llx(tl Cos d t
g. x(=) ilOllI X(3)ll Ccs o(r
O,X = llgil [ l'11 Cos o(z =
O. x(4) = llel llx(4)[ Cos 4+
+ long os *he o x lies in fegbn
A* Iong qa +1e vectoy X Jiee iwQegion2-
fyre ongte betrueen wtll be betuoeen
o 10 T / 2- flaerc, $o.e Tvre angte betrrleerr , hltlt be betr,oeeh
tI/Z Lo rr
g.x >o for^ttX inR2ranl
0. X ( o {ar al,L X ivt R21on 2-
2.12
,.\
q/ d>
,\
s X1
Ao to coneLrde
,x(6r^l tere r+e rnill ree 3 degrce oJ {reedout 'th"t r"re .still har,re. .
/o oll hzr.qil^ev\^.oh,cat {or*latton , h]e Aotnl +tU nouJ r,oornl get c{{e&d
t,T hle use O oY cO r,there c.Ge-
lnis is a degree e/ Jneedowu rce Vrqrre, ie \de or€ f".ee *o choose elv\d:
posihlre, uzr"ulttpte qg , arr,d oux decrston botrnd*J anl. cto,r.li$'er ,,&t[
the -sqta4.g
reyrrto[yt
Dut ttote *hat if I ,A reptaced by cO . Ttre vroym o{ rrec*or change
ie tle ll = 9,1 + Do"
Srsb 'tet( leneralise f* +hu case ,livte ond noL juat &1u
posstn5 -throu6[,u *W* .
"J "ry
2.75
)Tne generol cqse 0o # o
C$ gou dorr,t wol,rno be bothered t"'d+iL .lome tedtotrs cqlcularkoa yatr can
:ktp
be :'inatuar!9r
*,tis pozt ahd, qssume youvset{ +lrot-the clossiJrer ![or't*uis e,sewtll
delined but i{ you qre curtous heres h}hati ho'ppeninX
> Trre equa*t'oe { .trne ts
er 2(r * 9: Xr-* 9o -- O
ITEII
ool
)
.c
/o {his is
,q
il?ilcos< : Prol'ec*corr oJ arly rcctar,X +
oto.tg d rs diracte on
r
tgol : Perpendiculan disfance ol llxllCos*
ll9ll 'lo {he ltvte
g,,tr'6ura-
dertred beJorle q @
v
.6F
q9\
Gr any rre,c-tor X t'vt R.e6ron I
J
tnereforre x.b^ (6.x.*oo) > o
st or,y rreclov x ir,r, Re2'ton 2-
+
+ +'+ Herre, hle -,\ee Eome {taining data,
++ +
we see +here cqvl be no line {hrough
+ ovr.gun, rihot corv'ec\ cta,s,l,.L{rer
otl the potvtts,
\ Bub *herae altll con be rrT any irnes
[e ltrzreerrt ClqrAit u, 'thot con do
or-rx job
Some CI.ve dravoar'
tr Ljneolc Seperafio4"
Jo hle -rqu, eayJier( ,tla-ct in ar.der to Jtna o ctossilier.'{il.*d,, h UNEAR,
ifie polrafa in trotnrng reL correctty r v\.]€. vttll need ,aorne conditcoa
and cto,g,r,t$er ALL
to loe xattsfied ond {rtror co rr-ditan is folto r"xng i
T\"r.t is vedundaYtt
Out +his d{inilton is rneeded jcrr{fte ney* aLgoriU.m 'lh-o+ h}e q}^e oborrb
to ,uee c^orLled the perceptron . rryhich rrelies on {he foct +fia}
o" .&rlb.thwy,^ltll be {ound lor A rre,ctoy avtd oo e}!*et pa'tavneXer
ontg if Sn is ktnecr.hT beperable. But {trs{ let( cafculat'e traintng errna in,tfuscare.
2.,2o
htx(i)) : g.x(i)+9o
h)e otso fq"vrdout that (vrespecltve "l *h. lobel t+t * -rt if
,til 19. x(i) *go ) > o 1laen point ts cott€c+lyr elu*'i{."d
ts
,til (g,. )c,i) + 0o ) <o *he potn* vnis ctossi$ied
lvrere is o cose rnyhen &*fute uectar wtll lie on *he hJperplane [line
here ) irn -thott cose
o.)c(i)+0o -o E+ y(i,(9"1ri)+go) -o
y0e r*ft[ a\so consider 'th,r's co.se qs an qryc( , heccruse xnr^eotly
donrt Knoltr hovo 1o ctosst{y it
.If you rernembev ltre If. n double bracl<et rroha]ton r h.]€ hod
Noto t^r€ t^'tlt ftnolty see l.he PercepLran Atgori*ftrn , *hot Snds d
li4eor cto,ur{ter , iJ {hene exisK ore .
F FERCEPTRoN
tnsteod o$ Lqytng the algorithrn onyou,yug tocmld rather aee fuot '&comes us
Seometrtea.lly . Now hoEe t{ac.t !r1re oY€ here, in seo.rcla- "J q- Une ,lcuE it 6 +futtJ
clectded , ohce vue l.uqrve tlae rrectoy 9.
{so nobe {nab r vtre voctl see lfie cqse oJ {lne possing )htou{* mLgtn , i*t fox.
,sintplici*3 .
{so in ordey Jor t}us atgorithln- lo be ruccessfuL , r^re need ltneartg aeperable daka,
fe rue tnxtl need poinlstlaat conLre c\iutded/classi{ted by o Jtyr,e,
Ge ponsl-Line/ decrston bound,oly tnrill be perpendlcula'u to -tlae g vectrr oluraXx.
L.at us loegrrn"
) Leks fivst -roy tilr-at 6 {s t3l
1st Poilrb
ttl o
1
5++1 int
@ 0
{he 5{h potnt
-l
Now corvregthe trtcky part', Lel3 sqy +
eutcounterred by otgovi*hna ia
xtr) = -labeL -1
-{
LI'J 4
0 new
til 1
| :,j I';]
2-.23
@
?((6) -2_ lobet = *1
=
-.2D
I (t)
6. x(t))
*he poivr* t^)ill not lce properly ctassified beco,se y (
-gn"u'
J
0old
a
I
f +
0
A I
+
y(6.)*tcl
@ e/
@
OOPSIEe eeeo
rae-c+ov d cloes
t'r.6t r^rhevr you then Bl"t , \^)e hlere alc oub -lo end. Th" ne^)
-potnts properlT "
@ & @ otre. ovr
ttre utrcrr/\g t tde
hot classtfy qlr. the
How do You jeel ? Do You {eel
like an idiot nounr !
you ore one You suck.Ll.l, ' Borroa t!\
nlell you should , becouse '
l:; l+e,,\1]
=f il vrYlnen rare sdavled
O.go.trr"
IioL{rrL 1
+ +
h)e nornlfio.re a ttnec.rt repeva*oz &
hle dont* rneed *o .t.ook at Jurttrer
points because ff"y o.r.e atready 1 -l
Correcfty cto*a{tecl ), ,,rwnt +
,J
Change g ./o o
I
2,25
,So *fre Atc ori*hm is sornethlng like {r"x
Inittqlize g =O
Choose a Sequence ft* 1 {o rr- lo tterate ovrgf,
*or {oop in i
check if ytit 1g.x(i)) <. o 6o to
next
UYrs d = d+ Ytirltil (
b N o Dor* do onY*hing
Afier end { f"r( I*p
,T d ctaut$es all potnl( correc!
urle found *he ctassi$er . ENDc.oDE
iS not sruulJte -l*re indices
{oo 6
--s
9r We hlill add Xr
g Oz on oddittsna\ 2L2
x
9a Ito :
2Ld
Oo d+l xt *kre lost- elernenl-
o{ ecrch $nture
I
)
d+l x1
\nectoy .
Check
"t
t hny code l2_perceptron_visualization.ipynb in the shared folder
to wsuaLize a peTcep*ron
FIN"