Python Programming for Biology: Bioinformatics and Beyond


Figure 24.7.  Example output for an SVM classifier with two data dimensions



Download 7,75 Mb.
Pdf ko'rish
bet409/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   405   406   407   408   409   410   411   412   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

Figure 24.7.  Example output for an SVM classifier with two data dimensions. The

input SVM training data is shown with black and grey circles representing the two data

categories (left). The support vectors are indicated as the circled points. The prediction

result is displayed over the whole data range, to illustrate the classification boundaries

(right). The category for each point is illustrated by being a black or grey shade.

The following Python code tests the trained SVM on a whole range of different points

in the plane between 0 and 1, thus showing the shape of the categorisation boundaries. The

distinction between the categories is made according to whether the prediction is greater

than zero (positive) or not. Note that the x and y values for a given query are appended to

lists  so  that  the  data  can  be  displayed  as  graphical  scatter  plots,  using  the  helpful  pyplot

library (from MatplotLib).

from matplotlib import pyplot

ds1x = []

ds1y = []

ds2x = []

ds2y = []

x = 0.0

while x < 1.0:

y = 0.0

while y < 1.0:

query = array( (x,y) )

prediction = svmPredict(query, data, knowns, supports,

kernelGauss, params)

if prediction > 0:

ds1x.append(x)

ds1y.append(y)

else:

ds2x.append(x)




ds2y.append(y)

y += 0.02

x += 0.02

pyplot.scatter( ds1x, ds1y, color='grey' )

pyplot.scatter( ds2x, ds2y, color='black' )

pyplot.show()




Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   405   406   407   408   409   410   411   412   ...   514




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish