Python Artificial Intelligence Projects for Beginners


Making a confusion matrix for the data



Download 16,12 Mb.
Pdf ko'rish
bet30/65
Sana02.01.2022
Hajmi16,12 Mb.
#311589
1   ...   26   27   28   29   30   31   32   33   ...   65
Bog'liq
Python Artificial Intelligence Projects for Beginners - Get up and running with 8 smart and exciting AI applications by Joshua Eckroth (z-lib.org)

Making a confusion matrix for the data
Let's make a confusion matrix to see which birds the dataset confuses. The
DPOGVTJPO@NBUSJY
 function from scikit-learn will produce the matrix, but it's a pretty big
matrix:


Prediction with Random Forests
Chapter 2
[ 36 ]
Two hundred by two hundred is not easy to understand in a numeric form like this.
Here's some code from the scikit-learn documentation that allows us to plot the matrix and
the color in the matrix:


Prediction with Random Forests
Chapter 2
[ 37 ]
We will need the actual names of the birds on the matrix so that we know the species that
are being confused for each other. So, let's load the classes file:


Prediction with Random Forests
Chapter 2
[ 38 ]
Plot the matrix. This is the confusion matrix for this dataset:
The output looks like the following:


Prediction with Random Forests
Chapter 2
[ 39 ]
The output is unreadable because there are 200 rows and columns. But if we open it
separately and then start zooming in, on the 
y
 axis you will see the actual birds, and on the
x
 axis, you will see the predicted birds:


Prediction with Random Forests
Chapter 2
[ 40 ]
For example, the common yellow throat is the true one. Looking at the following graph, we
can see that the common yellow throat is confused with the black-footed albatross. When
we zoom out, we will see the confusion:
It's like a square of confusion that was there between the common yellow throat and the
black-footed albatross. Some features are terns, such as the arctic tern, black tern, Caspian
tern, and the common tern. Terns are apparently easy to confuse because they look similar.


Prediction with Random Forests
Chapter 2
[ 41 ]
This set is a little bit confused too:
This is the set regarding sparrows. The confusion matrix tells us the things that we expect,
that is, birds that look similar are confused with each other. There are little squares of
confusion, as seen in the previous screenshot.
For the most part, you don't want to confuse an albatross with a common yellow throat
because this means that the dataset doesn't know with what it's doing.


Prediction with Random Forests
Chapter 2
[ 42 ]
Since the bird's names are sorted, lesser is the square of confusion. Let's compare this with
the simple decision tree:
Here, the accuracy is 27%, which is less than the previous 44% accuracy. Therefore, the
decision tree is worse. If we use a 

Download 16,12 Mb.

Do'stlaringiz bilan baham:
1   ...   26   27   28   29   30   31   32   33   ...   65




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