0% found this document useful (0 votes)
10 views

ML Assignment 2

Uploaded by

1ep21ad039.ade
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

ML Assignment 2

Uploaded by

1ep21ad039.ade
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

ASSIGNMENT- 0

(o ontext to
poepae e data tor Mh algon thms, wt a
noti

() Rato leantng
Most Me alo cont ok oth nisTng jeatnes. totalbedomy
NL
attibut has some sing values. Ths an be fued boy 3qptens
3

* Get vd o the coma ponding ditsst


eet id the olde attbibutt
medlan etc)
Set the values to ome value Czero, mean,
be auomplahed by wng Aatirame dopna l), dhap(),
and Flna) mettods:
howsing.cropral subset ="totd bedtomJ) #oçton1
howsing- drop ('to ta-bedooms" axù a)
meianz houng C"totat bedraaJ. mebanl) Fotbn3
hou gCbtalbeduoma"J flnalmian, inplae=Ta)
Srkt kearn poucs a
handy austo tke cau
SnpleTnpute
irst tounedto wat a Simple Dmpte tnstane, ptyong est
yrou tar to place eab attibidi s mising nalues oith ito nas
thor sklean. imipti tmpox4 SmpkImputr
tmuty Simple Inputn (stratcgye"medan")
Since the median can only be tomp uted on mwial atbibutes,
we need to t a copy oh daa othot text ottibua otean.

howingnu houing- coqp'bcan-proimity aeis )


Rt he imputes iMtane to traning
Trpud. t [houing-u)
Jth sate to apey the tmpter to al umeeal ottsibustes:
imputen. btatisi e
34- Q6, 4., 9-5, y33-, W64, yD8., 3, SDo?])
>>> howing -nun. ned'as ). velues
U-8-s 34-6, a9-, 9. 433.,V64-,82.,3.5Ho9)
Aahed" ivptto tbarfor tang set by rplaung miu
values by te leaned medons:
inputes. tanstoar Chouy ing nunn
yut
To
plarn nPy amay
t it bak tro a Pandes Data Prannei
contoning tanfomd feat
howing-tr = pd.Rata Famelx, toums =housrgu. ol
(*) Handlmg teet and cabsgon'eal attsbuts
Reaie we out Cadegorial atibut ocean-pomity because
it iàa text atbibuto so e can't cermpute its meclian:
housng-cat housng C" ocean- poromity°JI
>>>> houng-at. headl)
oceanprox irity
17606 <IH OUEAN
(86 3
<LH DcEAN
1465D NEHR oEAN
B30 LNLAND
35S

conmert these eatsgones tom tet to nn, weuse Scikt-leas


DrdinalEncode las:
tor sktan. ppowng mport Ordinal noode
>>>ordinalenden z Ddnal Bruclest)
7> housing- catedad ovdinal-enuades -fit tansfoyr(loussg
housng lat erodedC:L9]
anay CLlo. J,
Lo.J,
[4.3,
Ch.3,
Co.J,
C1.].
Co-3,

Co.3,
[o.33)
ot o catgoies Can be obtauned categoies-istane vasable
erdinal-enudey- atgones
[arcy L't oCEANS 'iNLAD, LAND, 'NEAR BAY
'NEAR-DEA
dhype objeit]
nearby lues moe Nulas than foo i fat vales,To
wyed. he ne att buts are
called duMMy atlsibutey. sukit- hean proud a Onetot Ereccly
laws to conuot categotal values nto one hot vectos.
tom toasn- peproesing inpost onetotEnuoder
>>> cat e d = One tot recclenl)
howing- cat lhot = at encodez. ft franafoo lhouing cat)
housing-cat- ihot
spavse mabi f type c' lavs 'nmpy- Hoat ty's
oith Ibsla stoyed
toxed elennt
eleent in
in comprened spane Row tornt
The cotput SaPy spase mati, istcad fa Nunty may.

(T) Featuse Salm9


* Most inpovtat tanjomehors
algo dont .peofom etl ebhen mpd
Wumwial attibuts lane vey dajeset sales. This is te caye sor
data: he tota ne oj ooms srges ton abod 6to 39, 3o0,
toung
eile the medien tnoms oly angs tom oto Ls.
thse are too orman iays to get al atoi bitas to haue ane
sale: minmaN and standardsaton
scalng lnommalis aton): values ae
hat end up vanging thor oto l. we do this by subtsatng the
wIn vale and dindng by max in us min. Sukt -heasn
pudes tasfomes caled MinMax Scalan. Hhas a teahune vage
ypeporamts that eti
ati to dange the enage is you don t
wat o- tor bove
standandisaton: fTat Tt butb
ubt aii the mean vae Calwys
have a 3ene man), and thenit divdes by standard deiato
0 that the vs ulting ditnbution has wnit vaiance
Sukit- Leasn povcdes tastormen Called
tor btandandigahan.
Standaod Suly
he ate snippets how how Srd Seunch
ondomied Seaneh halos co Fine
to Turing a wmadel.
Fine Twning

Sckit-keand td SeardheN to scareh for you. l


hypNparumetes you
to do is tell it wstich
sOth, and ohut values to ty out and it oill ewalat
al the poMible lonbinatns o hyperpanamuten value, umg
toos vali dato
ÉN: The follouong coe tecnhes for fhe bet combnaton f

form sklaasn.madel beleution impost GritSeamchc


panamgde I
§'netimatora': [3, 10, 30J, 'ma) featoes': o, 4,6, &J3,
$'botstap': [False], netiratox':[316], 'mar tante
La, 34]3,
focscteg =Rondom Foet Ragewosl)
id warche GrrdSeanch wfosctg paramgd s,
Song ngmean suaredo,
vehntain Loe =Tre)
qsd wohaft Choing-ppad, houang. labeb)
This paarm- gpr d sells SuiEt heanr to fst evaluat al
Bx 4=l3 Connbhaton of n-estinmatos and mas features
hypenpanamet vales peited in tiwat dct, then tny al
2x376 tombinatons
but is tme noth bootstap hppaAMt st to Fabe
noted
4ed of Tyue.
the
Combinatior o} RandmFoseset Ryor hypenpametea vales
wil toain ea mod c imes ., Th will be L&rs=90
and t
younds ob tranng9
qnid eaneh. beat panams
imaxteatwe':&, 'o-ettmatos': 303
(n ths ex, we cotan the best o by settng the ma-ttatue
30. The RIMSE AOe
hype paramtto & and n-estmetos to
tombinatn i 49, 68 ioloct i sbghetty beltes hes
tor this

Randomied Seanh
ohen the hypepaameto arh spae is lage , i is en
pfrablu to wse Rardomized Seanch, than grd Ceaoh
trstead ot'taying al pasible ombinaton, t. vauades a
t
ng od vandor Conbiratio» by welating ea rzndom value
aien ne
fos eah hypepanamto at woy tenon
appach has tw0 ma bonat
gou
o00
ttisapprDah oi ll enploe
-met.
You hane mose Contsol oes he orputng budlgct
wad fo alocate to yper pamt scach, sply by acbng
the no oh itenatons

3.
Code Snippeto, ottine the contapti inuoed in
() Meaning auray wsng CrOs-validaton
Ue Craws val- sa0e() tuncton to evaluat SGDdasif
mdel wng Ktold (us-valdaton, oith 34olds.
tom stléann. madel- pelutionimpost valore
cLAVal-oe Cs¡d- lf, tain, Ythain,s; cv= 3,
soing "aaay")
anay C Co. 96 3SS , 09345, 0.9st1S])
Bbove 43/ a y .
* clastes hat just clats ey gemage fn nots"
las:
trors skteasn. base imot Baseksimatos
las Nerengclsfiy CBaseEstimato):
dleB ttCselt, x,y none):
s
det.pedicdcselt ):
yetn npenos Cllenlx),i), dtype bool)
>>> nee) s_ Neey s claiffenl)
>>> ws Naoe Cnewes-d, -tan, ytoain-S,ou3,
aewnay")

shnply beeaus e
rb you away gues Ht images not s, you wl be
igat about g0- o7 time.
(o9 Conhusioo Maix
The tdlo is to cout u no oþthnes Imtaneof
las dasiped au das B.
fhorm sklean. madel seluion imçort (es awal-prolt

-toar, W>3):

Ktods es- vocdaion, bt instad ch etnng the


pacdctos made eaul
Aest told.
»kleann.metsio impost congibn- mabrK
bortuion-matstx Cy-ban-s, tha n-pred
CLCs3oSt, ISea],
L3s yo9633)
wrtusbn.matx acprsent as utual clas Lstih
eash columo poesons a pd tel elas.
* fst et hi matiy coyide non - S simages (-e
her we covetly uans fed
claw): s3, ost f the
negabves), wie sernaming I, SJs
oongy dasited as sh yabe te).
-The Corsdes tte image of ss Ss te can):
1325 were lausified as non -Ss
oongly dasited -ss Cjalse -e),
telia naning ,096 wee
comectiy dasted
Ctrwe poites.
pertt laso vould hae only tre te and tne-e
bo tonguson noty oould hawe nty tonzero onyop
nain diagonal.
Y-toinp tet pdictions =y-tsain-s
conguion-robrxpban s, ybain-petet pedton)
SHTI)

(ii) Preision and Reeall


he contuson mabi a lot o nto, bt sometes prefes
Lonuse matrc. to Dne -to ook at s t e

te prd ton calle poisio


precislon
TPtFP

tyically twed oong Oth anothe mobic nomed


veeal also caled sensihity os true pas ie nota ER CTPR)
his is the tio ol the itane that Lovey
dotted loy the elasiten

TP+EN
Geikt- kesn potdes eenal tunthors to Bnmput
claiien metaies tnelding preusior and eeat!
skleann. ntrs tmport paeeisicnSo, eeall-coe
poeusibn-DOe Ly-tans train
D. 9o8 &D836s4666y
>>> weal- soe ly- bratn-5, ybrarnped)
D-TosSROe83604y

ors solearn.mebstes

ot4209b 20436633S

H. orth the code bnizpet epain hoo. Multilabels


claitp ato dijoet ton imaltdas Mulhi'ontput elaustuha
Muthtabd clansticatar: Adanfcatn oyaterm hat cutputs
mulbple bineay tago.
fom stlean. nuglbors ipost klaglbors tlavitey
y-taan-laye = y taan> ) .
y-taùn-odd
y-multhi tsbd = ng-c-Cy-barn- lag, y-brein add]
knn- lt KNegubes Clautc
krnit totltn, multlabel)
4multilabel
code
udasng
to tanget labele for eat dgit image
Tnoiates ohethes or not the d t lange (1, &, ox 9)
and the beond sndiaks ohether
he next tnes et akNaghbos Casifes instane and
kyan rt wsing the mutiple tonget aay. Noo you
tan make a pdi on d nota that it o utpta

aray CCfalse, Tued])


And it qeta it igty thedyit s iss ndiad not tge
CFalses cnd odd Crues
Multioutput clausi icalian
4 is genesalaton mutti label lanitcaton olere
mutas Ci.e, can hae
eah abel can be
than oo posible value)
kets sat by reating the tianing and tost nets by
MST images
imegs and adding nose hçx
taking idensihes w,ng Numy's randitC) tuntion. The
piae
togt mages oil be he onginal images.
np.andom. randit Co, ioo, Clen Cx.train), #84)
np
Xtainmad X-tsain t noae
nosez np.undan.ndnt Co, Loo, Clen(xtest), R4))

y-tban-md = xtain
y - t t mad z x_test.
the clate and make he mage clean :
tranng
knn.ut. tt Cx_toan_mod, ythanmed)
dean dgit knn ct-pxdit clx testmad Csomendo
plot dgrt (cleon digit)

You might also like