Python Artificial Intelligence Projects for Beginners



Download 16,12 Mb.
Pdf ko'rish
bet22/65
Sana02.01.2022
Hajmi16,12 Mb.
#311589
1   ...   18   19   20   21   22   23   24   25   ...   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)

sex

Mjob
, which is the mother's occupation; 
Fjob
, which is the father's occupation;
reason; and guardian. Others, such as 
age
 and 
traveltime
, are numeric. The following
screenshot shows the second half of the attributes from the data:
It is clear that some of the attributes are better predictors, such as absences and the number
of past failures, while others attributes are probably less predictive, such as whether or not
the student is in a romantic relationship or whether the student's guardian is the mother,
father, or someone else. The decision tree will attempt to identify the most important or
predictive attributes using this information gain provided. We'll be able to look at the
resulting tree and identify the most predictive attributes because the most predictive
attributes will be the earliest questions.
The original dataset had three test scores: 
(

(
, and 
(
. Where 
(
 would be first grade,
(
 being the second grade, and 
(
 being the final grade. We will simplify the problem by
just providing pass or fail. This can be done by adding these three scores and checking
whether the sum is sufficiently large enough which is 35. That brings us to about a 50%
split of students passing and failing, giving us a balanced dataset. Now let's look at the
code:


Building Your Own Prediction Models
Chapter 1
[ 17 ]
We import the dataset (
TUVEFOUQPSDTW
), which comes with semicolons instead of
commas; hence, we mention the separators as semicolons. To cross verify, we will find the
number of rows in the dataset. Using the length variable, we can see that there are 
rows.
Next we add columns for pass and fail. The data in these columns would contain 1 or 0,
where 1 means pass and 0 means fail. We are going to do that by computing with every
row what the sum of the test scores would be. This will be calculated as if the sum of three
score is greater than or equal to 35, 1 is given to the student and failing to that rule 0 is
given to the student. 
We need to 
BQQMZ
 this rule on every row of the dataset, and this will be done using
the 
BQQMZ
 function, which is a feature of Pandas. Here 
BYJT
 means use apply per row
and 
BYJT
 would mean apply per column. The next line means that a variable needs to be
dropped: either 
(

(

(
. The following screenshot of the code will provide you with an
idea of what we just learned:
The following screenshot shows the first 5 rows of the dataset and 31 columns. There are 31
columns because we have all the attributes plus our pass and fail columns: 


Building Your Own Prediction Models
Chapter 1

Download 16,12 Mb.

Do'stlaringiz bilan baham:
1   ...   18   19   20   21   22   23   24   25   ...   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