Reference no: EM133482258
Objective: build understanding of Support Vector Machine classification
Load the "iris" dataset from sklearn.datasets. Split the dataset into training and testing sets, with a 70:30 ratio, and set the random state to 42.
construct a Decision TreeClassifier model and fit it to the training data.
Generate predictions using the trained model on the testing data. Calculate and print the accuracy of the classifier.
Visualize the Decision Tree using the graphviz library. Save the resulting visualization as a PDF or PNG file.
Regression:
Question: Load the "boston" dataset from sklearn.datasets. Split the dataset into training and testing sets, with a 70:30 ratio, and set the random state to 42.
Construct a DecisionTreeRegressor model and fit it to the training data.
Generate predictions using the trained model on the testing data. Calculate and print the mean squared error (MSE) of the regressor.
Compare the performance of the DecisionTreeRegressor with a Linear Regression model from sklearn.linear_model. Fit the Linear Regression model to the training data, generate predictions on the testing data, and calculate the MSE.
Give a brief reflection on the differences in performance between the DecisionTreeRegressor and Linear Regression models. Discuss the strengths and weaknesses of Decision Trees in regression tasks.