Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Homework 4 Use the scikit learn library for all the models except when mentioned to use another library. Review examples provided on Blackboard before attempting
Homework
Use the scikit learn library for all the models except when mentioned to use another library. Review examples provided on Blackboard before attempting homework. For most of the questions below you can modify the code in the examples provided. Please turn in a Jupyter notebook with the answers.
This homework is a continuation of HW Use the same Auto.csv dataset as in HW and the binary variable mpghighlow you created in HW
Split the dataset into training and test and use fold cross validation for the models below
Fit an SVM model to the training set to predict mpghighlow using all the other featuresvariables except mpg year, origin, and name. Use a rbf kernel and cost parameter found by tuning using grid search of evenly linearly spaced numbers in the range to and the gamma parameter found by searching evenly logarithmically spaced numbers with a start value of and stop value of hint: use numpy logspace Predict the mpghighlow using the test dataset and report the Accuracy, Precision, Recall, Specificity, and F measure.
Fit a decision tree model to the training set to predict mpghighlow using all the other featuresvariables except mpg year, origin, and name. Predict the mpghighlow using the test dataset and report the Accuracy, Precision, Recall, Specificity, and F measure.
Fit a Random Forest model to the training data to predict mpghighlow using all the other featuresvariables except mpg year, origin, and name. Use a nestimator parameter found by searching amongst the values and maxdepth parameter found by searching over the values and Predict the mpghighlow using the test dataset.
Fit a XGBoost model to the training data to predict mpghighlow using all the other featuresvariables except mpg year, origin, and name. Use a learning rate found by tuning using grid search of evenly linearly spaced numbers in the range to Report the accuracy, precision, recall, specificity, F score and AUC.
Fit a Stacked Classifier model to the training data to predict mpghighlow using all the other featuresvariables except mpg year, origin, and name. The models you need to stack are SVM decision tree, KNN and Nave Bayes. Report the accuracy, precision, recall, specificity and F score.
Summarize the performance of the all the above models by creating a dataframe with columns ModelName, Accuracy, Precision, Recall, Specificity, F Score. The data frame should contain one row for each model you built above with each of the columns filled in with the appropriate metric. Print out the dataframe. Which model performed the best from an accuracy point of view and which model performed best from a recall point of view? Of all the models you built in HW and HW which one performed best from an F score perspective?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started