Java
Java
age Salay
25.0 21000.O
2 25.0 21000.o
3 21-0 18000. O
3 33.0 45o00.o
5 38.0 50000. o
L45.0 63000.0
56.0 Nan
Nan 21000.0
53.0 4l000.O
55000. D
Tu: xdata. ilo , :-1
X
Oud: age
25.0
2 25.0
2 3 20
33.O
3
5 38.0
4
y5.0
56.0
53.D
8
40.0
y:data.iloc [:,-],alues
Tu:
ISoo0., 5ao
500., 50000.,
21000,
Outiarvay([21000., 55 o00.)
7lo00.,
6300 ) Man, 2loo0,,
21000,)
strateay:"umean)
x- iwje. fit transfom (2)
Y-y. reshaye Ci,)
4:ijo. fit.thausfovnaly)
Iy.resliajoe (-1)
out: array (tti:, 25.],
{l2., 25],
[3. 21],
[4.33],
[5. 38-],
I6. 45],
[.56.],
l8.2734.3333
[9.53],
Ho J])
Tu:
(E210oo., 2l000, l8000., 45000)
out: avay 40555. 55ss6
FBoe,) 2/oO0)
Foo00, 63o00
7l000. 5S000])
aditya lo 9
fail
32 20
fail kySr 8
28 nagati
Jpa5s
64
24 aditya
fasl G 5
31
22 pragati
joass 4
q9 23
4 3
20
23 Joass 3 2
fail adityaGko
33 2
Jorogai
19 ollge Gvo Out -o
marks vesul!
ota) dataset
-al pd.dalaset
isjpovt
Sels.
d
anthaining imto dolasel
Jeatuves the Scalg
Daling a)
calegovical
dala
with
ibvarieS, ython using tasks
datafollozoing the bate Dosons
Iu: Z: dataseB. iloc [:.[o. 2, 3)).
ales
y: datast. iloc /:.1), Dalue 5
from shlean.jr0te6ing iwjort
CabclEmcocdey, Ome Jlol Encoder
le-x: labelE ucodal)
x[:.0). le_x.fit_trasfom (zl:,o)
Ohe_arOuetotEmodr(ategorical-jeaaes
z: lo1)
olhe.fidtran sform(e).to os ay)
Cut avray ([lo., 1., 1, .. 1,1. oJ
1. 0.) O.) . , 1-1., OJ,
array (ll t,
Out : ar
i,O., o., ..., , l., o.
f, .,0., ..., 1., 1., 0.1)
Tu; xtest
Oul ay ([[l,O., O.,
[., o. ,o., ,o
l.,O.,0., .. , 0.]
(.,o.,o., I., ..., O.,
Tu:. ztest
out: aray ([t l.co00
Jákkavd Siuilarity:
Ta,B). lan8)
lAUB]
Gnplementaton
from skleam, metbrics iajport jacand Scove
4: [ , 1, o)
B= (2,2, O,1)
jau jaciard siove (A,B)
bint ('Tauavd Siilarity: o. sf '%jaiy
Euc(xy :/} («;-y)
jovograwM
Siey.Sjotial imjaort distane
dst = distane. eueli deau (ry)
jorint('uclidean distance : %3f %dst)
e MaubhaHam asta Mie -
Manlattan
|Tmplementation ythou
Spdial import distawe
Joa Gciy.
dst distauce, cityblok(ay)
dstauce: %3f' %dst)
Jbrint("Mauhattan
nanhotton distan ei lo.Y68