Question: Step# 2 - Upload the dataset data = pdread cssel'vertebrate.csv'header = 'infer' ) data Take screenshot of this output Step# 3 - Given the limited
Step# Upload the dataset
data pdread cssel'vertebrate.csv'header'infer'
data
Take screenshot of this output
Step#
Given the limited number of training examples, let's convert the problem into a binary classification task
mammals versus nonmammals
Student to code this themselves
Take screenshot of the original data with the new classification output
Step#
We can apply Pandas crosstabulation to examine the relationship between the Warmblooded and Gives
Birth attributes with respect to the class.
odcrasstabldataWarmblooded'dataGives Birth'dataClass
Take screenshot of this output
Step#
In this section, we apply a decision tree classifier to the vertebrate dataset described in the previous
subsection. We're going to use a Python library called "sklearn" which also supports calculating 'gini' as the
impurity measure.
from sklearn import tree
dataClass
X datardropName'Class'axis
clf tree.DecisionTreeClassifiercriterion'entropy',max depth
clf clffiti
The preceding commands will extract the predictor and target class attributes from the vertebrate
dataset and create a decision tree classifier object using entropy as its impurity measure for splitting
criterion. The classifier above is also constrained to generate trees with a maximum depth equals to Next,
the classifier is trained on the labeled data using the fit function.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
