Hands-On Machine Learning with Scikit-Learn and TensorFlow


| Chapter 5: Support Vector Machines



Download 26,57 Mb.
Pdf ko'rish
bet146/225
Sana16.03.2022
Hajmi26,57 Mb.
#497859
1   ...   142   143   144   145   146   147   148   149   ...   225
Bog'liq
Hands on Machine Learning with Scikit Learn Keras and TensorFlow

178 | Chapter 5: Support Vector Machines


CHAPTER 6
Decision Trees
Like SVMs, 
Decision Trees
are versatile Machine Learning algorithms that can per‐
form both classification and regression tasks, and even multioutput tasks. They are
very powerful algorithms, capable of fitting complex datasets. For example, in 
Chap‐
ter 2
 you trained a 
DecisionTreeRegressor
model on the California housing dataset,
fitting it perfectly (actually overfitting it).
Decision Trees are also the fundamental components of Random Forests (see 
Chap‐
ter 7
), which are among the most powerful Machine Learning algorithms available
today.
In this chapter we will start by discussing how to train, visualize, and make predic‐
tions with Decision Trees. Then we will go through the CART training algorithm
used by Scikit-Learn, and we will discuss how to regularize trees and use them for
regression tasks. Finally, we will discuss some of the limitations of Decision Trees.
Training and Visualizing a Decision Tree
To understand Decision Trees, let’s just build one and take a look at how it makes pre‐
dictions. The following code trains a 
DecisionTreeClassifier
on the iris dataset
(see 
Chapter 4
):
from
sklearn.datasets
import
load_iris
from
sklearn.tree
import
DecisionTreeClassifier
iris
=
load_iris
()
X
=
iris
.
data
[:, 
2
:] 
# petal length and width
y
=
iris
.
target
tree_clf
=
DecisionTreeClassifier
(
max_depth
=
2
)
tree_clf
.
fit
(
X

y
)
179


1
Graphviz is an open source graph visualization software package, available at 
http://www.graphviz.org/
.
You can visualize the trained Decision Tree by first using the 
export_graphviz()
method to output a graph definition file called 
iris_tree.dot
:

Download 26,57 Mb.

Do'stlaringiz bilan baham:
1   ...   142   143   144   145   146   147   148   149   ...   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