Question: 1 0 . 7 LAB: Random Forests for Regression and Classification You will use the same mpg . csv dataset for the following tasks. Load

10.7 LAB: Random Forests for Regression and Classification
You will use the same mpg. csv dataset for the following tasks.
Load the mpg. csv dataset.
Create a feature dataframe, x, using weight, model_year, and horsepower features.
Create a target dataframe, Y, using the mpg feature.
Y will contain the continuous mpg values for the regression model.
For the classification model, create a new column mpg_classes in Y that categorizes mpg values as low: (0-17), medium: (1729), and high:(29 and above).
Initialize a Random Forest Regressor with: n_estimators=100, random_state=100, max_depth=5, min_samples_leaf=5.
Fit this model on the x and the mpg column in y .
Print Feature importances and Mean Squared Error (MSE).
Initialize a Random Forest Classifier with the same parameters as for the regression model.
Fit this model on the x and the mpg_classes column in y .
Print Feature importances and classification accuray
* i am posting the whole question for full reference i really only need help with creating the new column for Y for the classification model which is the code shown at the bottom of the screenshot
1 0 . 7 LAB: Random Forests for Regression and

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 Programming Questions!