Which supervised learning algorithm is the best? For people who just start their machine learning journey, this question always comes to their mind.
To answer this question,we used 4 different types of data sets (One for regression problem, and the other 4 for binary classification problem) to test 6 supervised learning algorithms: SVMs (linear and kernel), neural networks, logistic regression, gradient boosting, random forests, decision trees, bagged trees, boosted trees, linear ridge regression. And also applied model Averaging to improve the models.
Table 1. Description of Data Sets  
Type  Data sets  # Predictor
Attributes 
Train Size  Test Size  Class Distribution

Regression  Boston Housing  13  253  253  – 
Binary classification  Wdbc  30  300  269  Malignant: 212 Benign:357 
Hypothyroid
(has missing values) 
34  1956  1134  Hypothyroid: 149negative:2941  
Ionosphere
(delete the first 2 predictors) 
34>32  220  131  Good:225
Bad:126 
For parts of the methods, Boston housing is trained twice, once with original attributes and once with scaled data. Also, to test the performance of logistic regression, Boston housing has been converted to a binary problem by treating the value of “MEDV” larger than its median as positive and the rest as negative.
Data Cleaning
Hypothyroid has lots of missing value, and 18 of 34 predictors are binary. The information on missing values and how many unique values there are for each variable are shown as below (Only shows the results of training data):
sapply(hyp,function(x) sum(is.na(x))) V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21 V22 V23 V24 V25 V26 0 277 44 0 0 0 0 0 0 0 0 0 0 0 0 278 0 429 0 152 0 151 0 150 0 1840 sapply(hyp, function(x) length(unique(x))) V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21 V22 V23 V24 V25 V26 2 89 3 2 2 2 2 2 2 2 2 2 2 2 2 202 2 67 2 245 2 151 2 244 2 44
A visual take on the missing values in this data set might be helpful:
We replaced the missing values with the mean in the continuous variables. Since there are few missing values in the binary variable “Sex”, and replace by the variable’s median or mean will cause bias, we deleted these 73 records. (training:44, test:29)
For the ionosphere dataset which contains 34 predictors, we have eliminated the two first features, because the first one had the same value in one of the classes and the second feature assumes the value equals to 0 for all observations.
Parameter Tuning Results by Datasets
I tuned the parameter by using 70/30 splits for training data and compared different models’ crossvalidation error. In addition, this report also used the Caret package in R to tuning the gradient boosting and random forest model. This section summarizes the tuning procedures and the results of each variable. By interpreting these results, I will choose the appropriate parameters for each algorithm.
Regression Problem (Boston Housing)
1. Gradient Boosting
The tuning result shows that whether data is scaled doesn’t affect the gradient boosting model. And when treedepth=5, the cross validation error is the smallest.
By using caret package, we confirm that the best combination is: shrinkage=0.001, number of trees=300, n.minobsinnode = 10 and treedepth=5. Part of the results are shown as below:
gbmFit1 Stochastic Gradient Boosting 253 samples 13 predictor No preprocessing Resampling: Repeated Train/Test Splits Estimated (25 reps, 0.7%) Summary of sample sizes: 180, 180, 180, 180, 180, 180, ... Resampling results across tuning parameters: shrinkage interaction.depth n.minobsinnode n.trees RMSE Rsquared RMSE SD Rsquared SD 0.001 1 10 15 8.337091357 0.6640256183 0.7941402762 0.09248626694 0.001 1 10 30 8.265578098 0.6722929163 0.7915189328 0.08870257422 0.001 1 10 45 8.195669943 0.6778771101 0.7895308048 0.08435275865 RMSE was used to select the optimal model using the smallest value. The final values used for the model were n.trees = 300, interaction.depth = 5, shrinkage = 0.01 and n.minobsinnode = 10.
2.Random Forest
The tuning result shows the crossvalidation error and Rsquared value, with different numbers of independent variables used to include in a tree construction. When mtry=6, the cross validation error is the smallest.
The results of caret package confirmed the choice.
rfFit1 Random Forest 253 samples 13 predictor No preprocessing Resampling: Repeated Train/Test Splits Estimated (25 reps, 0.7%) Summary of sample sizes: 180, 180, 180, 180, 180, 180, ... Resampling results across tuning parameters: mtry RMSE Rsquared RMSE SD Rsquared SD 2 3.290959961 0.8765870076 0.5079010701 0.01964500327 4 2.914160845 0.8946978414 0.3797723734 0.02067581818 6 2.826270709 0.8963652917 0.3505325664 0.02565374865 8 2.828542294 0.8932305921 0.3384923951 0.02829620363 10 2.856976760 0.8893013207 0.3504001443 0.02988188614 12 2.909261177 0.8842750778 0.3543389148 0.03184843971 14 2.964247468 0.8795746376 0.3713993793 0.03205890656 16 2.957650138 0.8801113129 0.3717238723 0.03240662814 18 2.955660322 0.8802977349 0.3745751188 0.03249307098 20 2.955327699 0.8802633254 0.3646805880 0.03206477136 RMSE was used to select the optimal model using the smallest value. The final value used for the model was mtry = 6.
3. Neural Networks
In this section, we used both original and scaled data, to find the difference. The scaled data’s cross validation error is smaller. So we chose the neural networks with neural networks with resilient back propagation, and the number of neurons in the hidden layer for the training process should be 6.
4.SVM (linear and kernel)
Since all the kernel methods are based on distance, so we need to scale the data set before applying to SVM model. The tuning result shows the crossvalidation error with different kernel methods. Since SVM will overfit training data easily, we will select the linear SVM with the cost=3.2.
4.Linear ridge regression For linear ridge regression, the result shows that we should choose lambda=0.01. We Can reduce this error by choosing the features, so rerun the same tuning process by choosing features=[ 6 11 8 10 13 ]
[…] those 4 classification problems, we also did the same processes as we mentioned in part I. Instead of going over the details, we would only show the model selection result of the four […]
LikeLike