Data Analysis From Scratch With Python: Step By Step Guide


plt.xlim(X1.min(), X1.max())



Download 2,79 Mb.
Pdf ko'rish
bet42/60
Sana30.05.2022
Hajmi2,79 Mb.
#620990
1   ...   38   39   40   41   42   43   44   45   ...   60
Bog'liq
Data Analysis From Scratch With Python Beginner Guide using Python, Pandas, NumPy, Scikit-Learn, IPython, TensorFlow and... (Peters Morgan) (z-lib.org)

plt.xlim(X1.min(), X1.max())
plt.ylim(X2.min(), X2.max())
for i, j in enumerate(np.unique(y_set)):
plt.scatter(X_set[y_set == j, 0], X_set[y_set == j, 1],
c = ListedColormap(('red', 'green'))(i), label = j)
plt.title('Decision Tree Classification (Test set)')
plt.xlabel('Age')
plt.ylabel('Estimated Salary')
plt.legend()
plt.show()
The most important difference is in this block of code:
from
sklearn.tree import DecisionTreeClassifier
classifier = DecisionTreeClassifier(criterion = 'entropy', random_state = 0)
classifier.fit(X_train, y_train)
When we run the whole code (including the data
visualization), we’ll see this: 


Notice the huge difference compared to Logistic Regression and K-Nearest
Neighbors (K-NN). In these latter two, there are just two boundaries. But here in
our Decision Tree Classification, there are points outside the main red region
that fall inside “mini red regions.” As a result, our model was able to capture
data points that might be impossible otherwise (e.g. when using Logistic
Regression).
Random Forest Classification
Recall from the previous chapter about Regression that a Random Forest is a
collection or ensemble of many decision trees. This also applies to Classification
wherein many decision trees are used and the results are averaged.
# Random Forest Classification
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
%matplotlib inline
# Importing the dataset
dataset = pd.read_csv('Social_Network_Ads.csv')
X = dataset.iloc[:, [2, 3]].values
y = dataset.iloc[:, 4].values

Download 2,79 Mb.

Do'stlaringiz bilan baham:
1   ...   38   39   40   41   42   43   44   45   ...   60




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