Question: Part 1 : Decision Trees ( DT ) - 4 pts . each task To complete the following tasks on DTs , you can use
Part : Decision Trees DTpts each task
To complete the following tasks on DTs you can use Python and libraries such as scikitlearn to implement your code.
Task : Hyperparameter Tuning Random Search
Load the Iris dataset.
Split the data into training and testing sets.
Implement a DT classifier.
Perform a Random Search to find the best hyperparameters for the DT classifier. Search for hyperparameters like max depth, min samples split, min samples leaf, and criterion. Hint: Use the RandomizedSearchCV function from scikitlearn.
Print the best hyperparameters and the model's accuracy with these hyperparameters.
Task : Error Analysis
After training the DT model with the best hyperparameters from Task use this model to make predictions on the test data.
Identify and print the indices of misclassified instances where the true class is not equal to the predicted class
Task : Confusion Matrix
Calculate the confusion matrix for the model's predictions on the test data.
Print the confusion matrix values True Positives, True Negatives, False Positives, False Negatives
Note: The following Tasks and were not taught extensively in class for DTs However, the concepts were covered in liner regression, so Id like you to give these a try wr DTs
Task : Regression with DTs
Load a dataset suitable for regression eg the Boston housing dataset from scikitlearn
Split the dataset into training and testing sets.
Implement a DT regression model.
Train the model on the training data.
Calculate and print the mean squared error MSE on the testing data to assess the model's performance.
Task : Metrics Comparison
Compare the performance of the DT classifier from Task and the DT regression model from Task
Calculate and print relevant evaluation metrics for the classifier eg accuracy, precision, recall, Fscore and the regression model eg MSE
Discuss the results, including which model performed better and why.
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
