Hands-On Machine Learning with Scikit-Learn and TensorFlow


| Chapter 2: End-to-End Machine Learning Project



Download 26,57 Mb.
Pdf ko'rish
bet51/225
Sana16.03.2022
Hajmi26,57 Mb.
#497859
1   ...   47   48   49   50   51   52   53   54   ...   225
Bog'liq
Hands on Machine Learning with Scikit Learn Keras and TensorFlow

68 | Chapter 2: End-to-End Machine Learning Project


Data Cleaning
Most Machine Learning algorithms cannot work with missing features, so let’s create
a few functions to take care of them. You noticed earlier that the 
total_bedrooms
attribute has some missing values, so let’s fix this. You have three options:
• Get rid of the corresponding districts.
• Get rid of the whole attribute.
• Set the values to some value (zero, the mean, the median, etc.).
You can accomplish these easily using DataFrame’s 
dropna()

drop()
, and 
fillna()
methods:
housing
.
dropna
(
subset
=
[
"total_bedrooms"
])
# option 1
housing
.
drop
(
"total_bedrooms"

axis
=
1
)
# option 2
median
=
housing
[
"total_bedrooms"
]
.
median
()
# option 3
housing
[
"total_bedrooms"
]
.
fillna
(
median

inplace
=
True
)
If you choose option 3, you should compute the median value on the training set, and
use it to fill the missing values in the training set, but also don’t forget to save the
median value that you have computed. You will need it later to replace missing values
in the test set when you want to evaluate your system, and also once the system goes
live to replace missing values in new data.
Scikit-Learn provides a handy class to take care of missing values: 
SimpleImputer
.
Here is how to use it. First, you need to create a 
SimpleImputer
instance, specifying
that you want to replace each attribute’s missing values with the median of that
attribute:

Download 26,57 Mb.

Do'stlaringiz bilan baham:
1   ...   47   48   49   50   51   52   53   54   ...   225




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