Question: Write a program that splits a dataset into training and test set, builds a classification tree, and outputs a confusion matrix. The program should do

Write a program that splits a dataset into training and test set, builds a classification tree, and outputs a confusion matrix. The program should do the following:
load the iris.csv dataset
create a dataframe, x, using the petal_length and sepal_length as features
create a dataframe, y, using species
split the data into training and test sets with 0.25 test size and random_state =0
standardize x_train and x_test
initialize the decision tree with criterion = "gini", random_state =100, max_depth=3, min_samples_leaf=5
run the decision tree on x_test
generate the confusion matrix
The output should be:
[[1400]
[0131]
[019]]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!