Hands-On Machine Learning with Scikit-Learn and TensorFlow


Logistic Regression | 147



Download 26,57 Mb.
Pdf ko'rish
bet122/225
Sana16.03.2022
Hajmi26,57 Mb.
#497859
1   ...   118   119   120   121   122   123   124   125   ...   225
Bog'liq
Hands on Machine Learning with Scikit Learn Keras and TensorFlow

Logistic Regression | 147


ing rate is not too large and you wait long enough). The partial derivatives of the cost
function with regards to the j
th
model parameter 
θ
j
is given by 
Equation 4-18
.
Equation 4-18. Logistic cost function partial derivatives


θ
j
J
θ = 1
m

i
= 1
m
σ
θ
T
x
i

y
i
x
j
i
This equation looks very much like 
Equation 4-5
: for each instance it computes the
prediction error and multiplies it by the j
th
feature value, and then it computes the
average over all training instances. Once you have the gradient vector containing all
the partial derivatives you can use it in the Batch Gradient Descent algorithm. That’s
it: you now know how to train a Logistic Regression model. For Stochastic GD you
would of course just take one instance at a time, and for Mini-batch GD you would
use a mini-batch at a time.
Decision Boundaries
Let’s use the iris dataset to illustrate Logistic Regression. This is a famous dataset that
contains the sepal and petal length and width of 150 iris flowers of three different
species: Iris-Setosa, Iris-Versicolor, and Iris-Virginica (see 
Figure 4-22
).
148 | Chapter 4: Training Models


16
Photos reproduced from the corresponding Wikipedia pages. Iris-Virginica photo by Frank Mayfield (
Crea‐
tive Commons BY-SA 2.0
), Iris-Versicolor photo by D. Gordon E. Robertson (
Creative Commons BY-SA 3.0
),
and Iris-Setosa photo is public domain.
17
NumPy’s 
reshape()
function allows one dimension to be –1, which means “unspecified”: the value is inferred
from the length of the array and the remaining dimensions.
Figure 4-22. Flowers of three iris plant species
16
Let’s try to build a classifier to detect the Iris-Virginica type based only on the petal
width feature. First let’s load the data:

Download 26,57 Mb.

Do'stlaringiz bilan baham:
1   ...   118   119   120   121   122   123   124   125   ...   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