Hands-On Machine Learning with Scikit-Learn and TensorFlow



Download 26,57 Mb.
Pdf ko'rish
bet77/225
Sana16.03.2022
Hajmi26,57 Mb.
#497859
1   ...   73   74   75   76   77   78   79   80   ...   225
Bog'liq
Hands on Machine Learning with Scikit Learn Keras and TensorFlow

>>> 
from
sklearn.model_selection
import
cross_val_score
>>> 
cross_val_score
(
sgd_clf

X_train

y_train_5

cv
=
3

scoring
=
"accuracy"
)
array([0.96355, 0.93795, 0.95615])
Performance Measures | 93


Wow! Above 93% 
accuracy
(ratio of correct predictions) on all cross-validation folds? 
This looks amazing, doesn’t it? Well, before you get too excited, let’s look at a very
dumb classifier that just classifies every single image in the “not-5” class:
from
sklearn.base
import
BaseEstimator
class
Never5Classifier
(
BaseEstimator
):
def
fit
(
self

X

y
=
None
):
pass
def
predict
(
self

X
):
return
np
.
zeros
((
len
(
X
), 
1
), 
dtype
=
bool
)
Can you guess this model’s accuracy? Let’s find out:
>>> 
never_5_clf
=
Never5Classifier
()
>>> 
cross_val_score
(
never_5_clf

X_train

y_train_5

cv
=
3

scoring
=
"accuracy"
)
array([0.91125, 0.90855, 0.90915])
That’s right, it has over 90% accuracy! This is simply because only about 10% of the
images are 5s, so if you always guess that an image is 
not
a 5, you will be right about
90% of the time. Beats Nostradamus.
This demonstrates why accuracy is generally not the preferred performance measure
for classifiers, especially when you are dealing with 
skewed datasets
(i.e., when some
classes are much more frequent than others).

Download 26,57 Mb.

Do'stlaringiz bilan baham:
1   ...   73   74   75   76   77   78   79   80   ...   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