Hands-On Machine Learning with Scikit-Learn and TensorFlow


>>>  bag_clf = BaggingClassifier (



Download 26,57 Mb.
Pdf ko'rish
bet160/225
Sana16.03.2022
Hajmi26,57 Mb.
#497859
1   ...   156   157   158   159   160   161   162   163   ...   225
Bog'liq
Hands on Machine Learning with Scikit Learn Keras and TensorFlow

>>> 
bag_clf
=
BaggingClassifier
(
... 
DecisionTreeClassifier
(), 
n_estimators
=
500
,
... 
bootstrap
=
True

n_jobs
=-
1

oob_score
=
True
)
...
>>> 
bag_clf
.
fit
(
X_train

y_train
)
Bagging and Pasting | 199


7
“Ensembles on Random Patches,” G. Louppe and P. Geurts (2012).
8
“The random subspace method for constructing decision forests,” Tin Kam Ho (1998).
>>> 
bag_clf
.
oob_score_
0.90133333333333332
According to this oob evaluation, this 
BaggingClassifier
is likely to achieve about
90.1% accuracy on the test set. Let’s verify this:
>>> 
from
sklearn.metrics
import
accuracy_score
>>> 
y_pred
=
bag_clf
.
predict
(
X_test
)
>>> 
accuracy_score
(
y_test

y_pred
)
0.91200000000000003
We get 91.2% accuracy on the test set—close enough!
The oob decision function for each training instance is also available through the
oob_decision_function_
variable. In this case (since the base estimator has a 
pre
dict_proba()
method) the decision function returns the class probabilities for each
training instance. For example, the oob evaluation estimates that the first training
instance has a 68.25% probability of belonging to the positive class (and 31.75% of
belonging to the negative class):
>>> 
bag_clf
.
oob_decision_function_
array([[0.31746032, 0.68253968],
[0.34117647, 0.65882353],
[1. , 0. ],
...
[1. , 0. ],
[0.03108808, 0.96891192],
[0.57291667, 0.42708333]])

Download 26,57 Mb.

Do'stlaringiz bilan baham:
1   ...   156   157   158   159   160   161   162   163   ...   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