Professional Documents
Culture Documents
Decision Trees - Jupyter Notebook
Decision Trees - Jupyter Notebook
{'UK': 0,
'USA': 1, 'N': 2}
In [1]:
CLASSIFICATION Means convert the values 'UK' to 0, 'USA' to 1, and 'N'
to 2.
To make a decision tree, all data has to be numerical. Then we have to separate the feature columns from
the target column.
We have to convert the non numerical columns
The feature columns are the columns that we try to
'Nationality' and 'Go' into numerical values. Pandas predict from, and the target column is the column with
the values we try to predict.
has a map() method that takes a dictionary with
dtree = dtree.feature_import
DecisionTreeClassifi ances_
def sortSecond(val):
In [ ]:
Regression In [ ]:
In [9]: In [10]: ) regressor =
regressor.fit(X, y)
regressor = regressor
DecisionTreeRegressor(
In [19]: In [22]: le =
preprocessing.LabelEn
coder()
from sklearn import encoder=le.fit_transf
preprocessing orm(features) encoder
Out[22]: array([0, 1, 3, 2], dtype=int64)
In [ ]:
In [ ]:
In [ ]:
In [17]:
References
1.
https://scikit-learn.org/stable/modules/gener
ated/sklearn.tree.DecisionTreeCla 2.