Question 7.2

Friedman (1991) introduced several benchmark data sets create by simulation.One of these simulations used the following nonlinear equation to create data: \(y=10sin(\pi x_1 x_2)+20(x_3-0.5)^2+10x_4+5X_5+N(0,\sigma ^2)\)

where the x values are random variables uniformly distributed between 0, 1.The package mlbench contains a function called mlbench.friedman1 thatsimulates these data:

set.seed(200)
trainingData <- mlbench.friedman1(200, sd = 1)
## We convert the 'x' data from a matrix to a data frame
## One reason is that this will give the columns names.
trainingData$x <- data.frame(trainingData$x)
## Look at the data using
featurePlot(trainingData$x, trainingData$y)

## or other methods.
## This creates a list with a vector 'y' and a matrix
## of predictors 'x'. Also simulate a large test set to
## estimate the true error rate with good precision:
testData <- mlbench.friedman1(5000, sd = 1)
testData$x <- data.frame(testData$x)

Tune several models on these data. For example:

knnModel <- train(x = trainingData$x,
                  y = trainingData$y,
                  method = "knn",
                  preProc = c("center", "scale"),
                  tuneLength = 10)
knnModel
## k-Nearest Neighbors 
## 
## 200 samples
##  10 predictor
## 
## Pre-processing: centered (10), scaled (10) 
## Resampling: Bootstrapped (25 reps) 
## Summary of sample sizes: 200, 200, 200, 200, 200, 200, ... 
## Resampling results across tuning parameters:
## 
##   k   RMSE      Rsquared   MAE     
##    5  3.466085  0.5121775  2.816838
##    7  3.349428  0.5452823  2.727410
##    9  3.264276  0.5785990  2.660026
##   11  3.214216  0.6024244  2.603767
##   13  3.196510  0.6176570  2.591935
##   15  3.184173  0.6305506  2.577482
##   17  3.183130  0.6425367  2.567787
##   19  3.198752  0.6483184  2.592683
##   21  3.188993  0.6611428  2.588787
##   23  3.200458  0.6638353  2.604529
## 
## RMSE was used to select the optimal model using the smallest value.
## The final value used for the model was k = 17.
knnPred <- predict(knnModel, newdata = testData$x)
## The function 'postResample' can be used to get the test set
## perforamnce values
knnEval=postResample(pred = knnPred, obs = testData$y)
knnEval
##      RMSE  Rsquared       MAE 
## 3.2040595 0.6819919 2.5683461

Which models appear to give the best performance? Does MARS select the informative predictors (those named X1–X5)?

MARS Model:

#MARS
marsGrid <- expand.grid(.degree = 1:2, .nprune = 2:20)
MarsModel <- train(x = trainingData$x,
                  y = trainingData$y,
                  method = "earth",
                  preProc = c("center", "scale"),
                  tuneGrid = marsGrid)
## Loading required package: earth
## Warning: package 'earth' was built under R version 3.6.3
## Loading required package: Formula
## Loading required package: plotmo
## Warning: package 'plotmo' was built under R version 3.6.3
## Loading required package: plotrix
## Warning: package 'plotrix' was built under R version 3.6.3
## Loading required package: TeachingDemos
## Warning: package 'TeachingDemos' was built under R version 3.6.3
MarsModel
## Multivariate Adaptive Regression Spline 
## 
## 200 samples
##  10 predictor
## 
## Pre-processing: centered (10), scaled (10) 
## Resampling: Bootstrapped (25 reps) 
## Summary of sample sizes: 200, 200, 200, 200, 200, 200, ... 
## Resampling results across tuning parameters:
## 
##   degree  nprune  RMSE      Rsquared   MAE     
##   1        2      4.383438  0.2405683  3.597961
##   1        3      3.645469  0.4745962  2.930453
##   1        4      2.727602  0.7035031  2.184240
##   1        5      2.449243  0.7611230  1.939231
##   1        6      2.331605  0.7835496  1.833420
##   1        7      1.976830  0.8421599  1.562591
##   1        8      1.870959  0.8585503  1.464551
##   1        9      1.804342  0.8683110  1.410395
##   1       10      1.787676  0.8711960  1.386944
##   1       11      1.790700  0.8707740  1.393076
##   1       12      1.821005  0.8670619  1.419893
##   1       13      1.858688  0.8617344  1.445459
##   1       14      1.862343  0.8623072  1.446050
##   1       15      1.871033  0.8607099  1.457618
##   1       16      1.875619  0.8597499  1.460975
##   1       17      1.879956  0.8591348  1.464279
##   1       18      1.879956  0.8591348  1.464279
##   1       19      1.879956  0.8591348  1.464279
##   1       20      1.879956  0.8591348  1.464279
##   2        2      4.383438  0.2405683  3.597961
##   2        3      3.644919  0.4742570  2.929647
##   2        4      2.730222  0.7028372  2.183075
##   2        5      2.481291  0.7545789  1.965749
##   2        6      2.338369  0.7827873  1.825542
##   2        7      2.030065  0.8328250  1.602024
##   2        8      1.890997  0.8551326  1.477422
##   2        9      1.742626  0.8757904  1.371910
##   2       10      1.608221  0.8943432  1.255416
##   2       11      1.474325  0.9111463  1.157848
##   2       12      1.437483  0.9157967  1.120977
##   2       13      1.439395  0.9164721  1.128309
##   2       14      1.428565  0.9184503  1.118634
##   2       15      1.434093  0.9182413  1.121622
##   2       16      1.471527  0.9145952  1.148351
##   2       17      1.473439  0.9145110  1.147595
##   2       18      1.464591  0.9158838  1.141467
##   2       19      1.461660  0.9161917  1.138989
##   2       20      1.464129  0.9159565  1.140982
## 
## RMSE was used to select the optimal model using the smallest value.
## The final values used for the model were nprune = 14 and degree = 2.
Marspred <- predict(MarsModel, newdata = testData$x)
MarsEval<-postResample(Marspred,testData$y)
MarsEval
##      RMSE  Rsquared       MAE 
## 1.2779993 0.9338365 1.0147070

SVM Model:

svmModel <- train(x = trainingData$x,
                  y = trainingData$y,
                  method = "svmRadial",
                  preProc = c("center", "scale"),
                  tuneLength = 14,
                  trControl = trainControl(method = "cv"))
svmModel
## Support Vector Machines with Radial Basis Function Kernel 
## 
## 200 samples
##  10 predictor
## 
## Pre-processing: centered (10), scaled (10) 
## Resampling: Cross-Validated (10 fold) 
## Summary of sample sizes: 180, 180, 180, 180, 180, 180, ... 
## Resampling results across tuning parameters:
## 
##   C        RMSE      Rsquared   MAE     
##      0.25  2.548095  0.7967225  2.001583
##      0.50  2.290826  0.8118225  1.779407
##      1.00  2.095918  0.8337552  1.634192
##      2.00  1.989469  0.8462100  1.539721
##      4.00  1.901332  0.8565135  1.510431
##      8.00  1.879815  0.8588126  1.514502
##     16.00  1.878866  0.8591568  1.518094
##     32.00  1.878866  0.8591568  1.518094
##     64.00  1.878866  0.8591568  1.518094
##    128.00  1.878866  0.8591568  1.518094
##    256.00  1.878866  0.8591568  1.518094
##    512.00  1.878866  0.8591568  1.518094
##   1024.00  1.878866  0.8591568  1.518094
##   2048.00  1.878866  0.8591568  1.518094
## 
## Tuning parameter 'sigma' was held constant at a value of 0.06670077
## RMSE was used to select the optimal model using the smallest value.
## The final values used for the model were sigma = 0.06670077 and C = 16.
svmpred <- predict(svmModel, newdata = testData$x)
svmEval<-postResample(svmpred,testData$y)
svmEval
##      RMSE  Rsquared       MAE 
## 2.0829707 0.8242096 1.5826017

Neural Networks

nnetGrid <- expand.grid(.decay = c(0, 0.01, .1),
                        .size = c(1:10),
                        .bag = FALSE)

ctrl = trainControl(method='cv', number = 10)
set.seed(200)
nnetModel <- train(trainingData$x, trainingData$y,
                  method = "avNNet",
                  tuneGrid = nnetGrid,
                  trControl = ctrl,
                  preProc = c("center", "scale"),
                  linout = TRUE,
                  trace = FALSE,
                  MaxNWts = 10 * (ncol(trainingData$x) + 1) + 10 + 1,
                  maxit = 500)
## Warning: executing %dopar% sequentially: no parallel backend registered
nnetModel
## Model Averaged Neural Network 
## 
## 200 samples
##  10 predictor
## 
## Pre-processing: centered (10), scaled (10) 
## Resampling: Cross-Validated (10 fold) 
## Summary of sample sizes: 180, 180, 180, 180, 180, 180, ... 
## Resampling results across tuning parameters:
## 
##   decay  size  RMSE      Rsquared   MAE     
##   0.00    1    2.409283  0.7621183  1.899438
##   0.00    2    2.422970  0.7596059  1.940174
##   0.00    3    2.050680  0.8164736  1.639116
##   0.00    4    1.945570  0.8359932  1.553962
##   0.00    5    2.459608  0.7843926  1.852817
##   0.00    6    3.619609  0.6518455  2.367746
##   0.00    7    3.732346  0.5465485  2.505487
##   0.00    8    5.341921  0.4925666  3.027228
##   0.00    9    4.448181  0.5628776  2.637284
##   0.00   10    3.736545  0.6189292  2.529286
##   0.01    1    2.380838  0.7641924  1.871203
##   0.01    2    2.456920  0.7487966  1.925584
##   0.01    3    2.152614  0.8037282  1.690702
##   0.01    4    1.926277  0.8453345  1.547266
##   0.01    5    2.129094  0.8103702  1.698914
##   0.01    6    2.140650  0.8117168  1.698805
##   0.01    7    2.414589  0.7646608  1.911319
##   0.01    8    2.366556  0.7741779  1.873354
##   0.01    9    2.368192  0.7641654  1.781225
##   0.01   10    2.336267  0.7855705  1.857180
##   0.10    1    2.392300  0.7614548  1.873846
##   0.10    2    2.437038  0.7557138  1.918843
##   0.10    3    2.136582  0.8043180  1.702665
##   0.10    4    2.009698  0.8245209  1.574401
##   0.10    5    2.015296  0.8345946  1.586740
##   0.10    6    2.038841  0.8283220  1.586032
##   0.10    7    2.129954  0.8133844  1.707177
##   0.10    8    2.148353  0.8099883  1.690601
##   0.10    9    2.254190  0.7942883  1.759231
##   0.10   10    2.359693  0.7719593  1.873586
## 
## Tuning parameter 'bag' was held constant at a value of FALSE
## RMSE was used to select the optimal model using the smallest value.
## The final values used for the model were size = 4, decay = 0.01 and bag
##  = FALSE.
nnetpred <- predict(nnetModel, newdata = testData$x)
nnetEval<-postResample(nnetpred,testData$y)
nnetEval
##      RMSE  Rsquared       MAE 
## 2.0603901 0.8320669 1.5289876

Compare the Model

eval<-cbind(nnetEval,MarsEval,knnEval,svmEval)
eval<-data.frame(eval)
colnames(eval)<-c('Neural Network','MARS','KNN','SVM')
eval
valuePre<-varImp(MarsModel)
valuePre
## earth variable importance
## 
##    Overall
## X1  100.00
## X4   75.40
## X2   49.00
## X5   15.72
## X3    0.00
plot(valuePre)

MARS model has the lowest RMSE, 1.277993 and highest R squared, 0.9338365, so it is the best performance model. For Mars Model, the most important variable is X1, and only X1, X4, X2 and X5 were selected to the model.

Question 7.5

Exercise 6.3 describes data for a chemical manufacturing process. Use the same data imputation, data splitting, and pre-processing steps as before and train several nonlinear regression models.

data(ChemicalManufacturingProcess)

# imputation

chemical<-kNN(ChemicalManufacturingProcess,imp_var = FALSE)


chemical_remove <- nearZeroVar(chemical) # remove predictors
chemical <- chemical[,-chemical_remove]

   

#data splitting,
indx<-createDataPartition(chemical$Yield,p=0.8,list=FALSE)
chemical_train<-chemical[indx,]
chemical_test<-chemical[-indx,]

X_train <- chemical_train[,-1]
Y_train <- chemical_train[,1]

X_test <- chemical_train[,-1]
Y_test <- chemical_train[,1]

a.

Which nonlinear regression model gives the optimal resampling and test set performance?

Neural Networks

set.seed(200)

nnetGrid <- expand.grid(.decay = c(0, 0.01, 0.1),
                        .size = c(1:8),
                        .bag = FALSE)

nnetModel_chemical <- train(X_train,
                  Y_train,
                  method = "avNNet",
                  tuneGrid = nnetGrid,
                  trControl = ctrl,
                  preProc = c("center", "scale"),
                  linout = TRUE,
                  trace = FALSE,
                  maxit = 500)
nnetModel_chemical
## Model Averaged Neural Network 
## 
## 144 samples
##  56 predictor
## 
## Pre-processing: centered (56), scaled (56) 
## Resampling: Cross-Validated (10 fold) 
## Summary of sample sizes: 130, 129, 129, 130, 131, 131, ... 
## Resampling results across tuning parameters:
## 
##   decay  size  RMSE      Rsquared   MAE     
##   0.00   1     1.551732  0.3524223  1.280294
##   0.00   2     1.488753  0.3639473  1.183896
##   0.00   3     1.546534  0.3902995  1.175509
##   0.00   4     1.859141  0.3684386  1.498639
##   0.00   5     2.069060  0.3168275  1.629967
##   0.00   6     2.204153  0.3695348  1.751427
##   0.00   7     2.570028  0.3319244  2.037320
##   0.00   8     3.820263  0.1579420  2.811813
##   0.01   1     1.481336  0.4439399  1.173887
##   0.01   2     1.430823  0.5597962  1.120769
##   0.01   3     1.462122  0.5185533  1.193115
##   0.01   4     1.703229  0.4294136  1.294110
##   0.01   5     1.860628  0.3793874  1.328236
##   0.01   6     1.608408  0.4514521  1.222713
##   0.01   7     1.580330  0.4276253  1.257689
##   0.01   8     1.378950  0.5321537  1.134111
##   0.10   1     1.657510  0.4473551  1.220769
##   0.10   2     1.481176  0.5434424  1.068092
##   0.10   3     1.607767  0.4559312  1.311747
##   0.10   4     1.788061  0.4134498  1.277393
##   0.10   5     1.954365  0.3922934  1.407200
##   0.10   6     1.863297  0.4070747  1.304668
##   0.10   7     1.975611  0.3909674  1.397907
##   0.10   8     1.937982  0.3722276  1.408850
## 
## Tuning parameter 'bag' was held constant at a value of FALSE
## RMSE was used to select the optimal model using the smallest value.
## The final values used for the model were size = 8, decay = 0.01 and bag
##  = FALSE.
nnetpred_chemical <- predict(nnetModel_chemical, newdata = X_test)
nnetEval_chemical<-postResample(nnetpred_chemical,Y_test)
nnetEval_chemical
##        RMSE    Rsquared         MAE 
## 0.007721307 0.999981598 0.006089000

MARS Model:

ctrl = trainControl(method='cv', number = 10)
marsGrid <- expand.grid(.degree = 1:2, .nprune = 2:38)
set.seed(200)
marsModel_chemical <- train(X_train,
                  Y_train,
                  method="earth", 
                  tuneGrid = marsGrid,
                  trControl = ctrl)
marsModel_chemical
## Multivariate Adaptive Regression Spline 
## 
## 144 samples
##  56 predictor
## 
## No pre-processing
## Resampling: Cross-Validated (10 fold) 
## Summary of sample sizes: 130, 129, 129, 130, 131, 131, ... 
## Resampling results across tuning parameters:
## 
##   degree  nprune  RMSE      Rsquared   MAE      
##   1        2      1.369833  0.4467048  1.0860424
##   1        3      1.211507  0.5686188  0.9589247
##   1        4      1.249621  0.5425630  0.9791137
##   1        5      1.274046  0.5475672  0.9918768
##   1        6      1.257202  0.5483783  0.9713915
##   1        7      1.286116  0.5268436  0.9977956
##   1        8      1.248025  0.5461736  0.9528328
##   1        9      1.219865  0.5599196  0.9497539
##   1       10      1.284223  0.5315448  0.9901312
##   1       11      1.304482  0.5262653  1.0010708
##   1       12      1.328601  0.5164286  1.0405815
##   1       13      1.431916  0.4656114  1.0807038
##   1       14      1.415393  0.4798418  1.0558050
##   1       15      1.405107  0.4831515  1.0462950
##   1       16      1.405107  0.4831515  1.0462950
##   1       17      1.405107  0.4831515  1.0462950
##   1       18      1.405107  0.4831515  1.0462950
##   1       19      1.405107  0.4831515  1.0462950
##   1       20      1.405107  0.4831515  1.0462950
##   1       21      1.405107  0.4831515  1.0462950
##   1       22      1.405107  0.4831515  1.0462950
##   1       23      1.405107  0.4831515  1.0462950
##   1       24      1.405107  0.4831515  1.0462950
##   1       25      1.405107  0.4831515  1.0462950
##   1       26      1.405107  0.4831515  1.0462950
##   1       27      1.405107  0.4831515  1.0462950
##   1       28      1.405107  0.4831515  1.0462950
##   1       29      1.405107  0.4831515  1.0462950
##   1       30      1.405107  0.4831515  1.0462950
##   1       31      1.405107  0.4831515  1.0462950
##   1       32      1.405107  0.4831515  1.0462950
##   1       33      1.405107  0.4831515  1.0462950
##   1       34      1.405107  0.4831515  1.0462950
##   1       35      1.405107  0.4831515  1.0462950
##   1       36      1.405107  0.4831515  1.0462950
##   1       37      1.405107  0.4831515  1.0462950
##   1       38      1.405107  0.4831515  1.0462950
##   2        2      1.369833  0.4467048  1.0860424
##   2        3      1.151354  0.6017934  0.9490535
##   2        4      1.195602  0.5683107  0.9789112
##   2        5      1.212729  0.5544613  0.9811140
##   2        6      1.259476  0.5233797  1.0149549
##   2        7      1.276080  0.5169745  0.9971014
##   2        8      1.254041  0.5358384  0.9816998
##   2        9      1.204493  0.5503540  0.9412522
##   2       10      1.217828  0.5565367  0.9512749
##   2       11      1.254498  0.5505529  0.9560064
##   2       12      1.255923  0.5703603  0.9365228
##   2       13      1.237292  0.5773041  0.9362430
##   2       14      1.220458  0.5997714  0.9346536
##   2       15      1.232675  0.5927902  0.9434397
##   2       16      1.210087  0.6020661  0.9195078
##   2       17      1.209727  0.6033106  0.9211479
##   2       18      1.290372  0.5759040  0.9509552
##   2       19      1.311399  0.5664008  0.9395244
##   2       20      1.306793  0.5680164  0.9390429
##   2       21      1.309745  0.5706859  0.9513013
##   2       22      1.309097  0.5702884  0.9501327
##   2       23      1.302850  0.5742954  0.9445891
##   2       24      1.315983  0.5697364  0.9521754
##   2       25      1.311220  0.5713247  0.9514975
##   2       26      1.302313  0.5724254  0.9544148
##   2       27      1.299771  0.5737160  0.9509811
##   2       28      1.299771  0.5737160  0.9509811
##   2       29      1.299771  0.5737160  0.9509811
##   2       30      1.299771  0.5737160  0.9509811
##   2       31      1.299771  0.5737160  0.9509811
##   2       32      1.299771  0.5737160  0.9509811
##   2       33      1.299771  0.5737160  0.9509811
##   2       34      1.299771  0.5737160  0.9509811
##   2       35      1.299771  0.5737160  0.9509811
##   2       36      1.299771  0.5737160  0.9509811
##   2       37      1.299771  0.5737160  0.9509811
##   2       38      1.299771  0.5737160  0.9509811
## 
## RMSE was used to select the optimal model using the smallest value.
## The final values used for the model were nprune = 3 and degree = 2.
marspred_chemical <- predict(marsModel_chemical,
                             newdata = X_test)

marsEval_chemical<-postResample(marspred_chemical,Y_test)
marsEval_chemical
##      RMSE  Rsquared       MAE 
## 1.1721267 0.5730574 0.9321591

SVM Model:

set.seed(100)
svmModel_chemical <- train(X_train,
                  Y_train,
                 method = "svmRadial",
                 preProc = c("center", "scale"),
                 tuneLength = 14,
                 trControl = ctrl)
svmModel_chemical
## Support Vector Machines with Radial Basis Function Kernel 
## 
## 144 samples
##  56 predictor
## 
## Pre-processing: centered (56), scaled (56) 
## Resampling: Cross-Validated (10 fold) 
## Summary of sample sizes: 129, 130, 130, 130, 130, 130, ... 
## Resampling results across tuning parameters:
## 
##   C        RMSE      Rsquared   MAE      
##      0.25  1.379436  0.4678935  1.1305379
##      0.50  1.275603  0.5142810  1.0315086
##      1.00  1.206832  0.5595208  0.9637462
##      2.00  1.126680  0.6117098  0.8992539
##      4.00  1.111241  0.6093522  0.8970187
##      8.00  1.097502  0.6125754  0.8950234
##     16.00  1.095846  0.6132911  0.8938544
##     32.00  1.095846  0.6132911  0.8938544
##     64.00  1.095846  0.6132911  0.8938544
##    128.00  1.095846  0.6132911  0.8938544
##    256.00  1.095846  0.6132911  0.8938544
##    512.00  1.095846  0.6132911  0.8938544
##   1024.00  1.095846  0.6132911  0.8938544
##   2048.00  1.095846  0.6132911  0.8938544
## 
## Tuning parameter 'sigma' was held constant at a value of 0.01466014
## RMSE was used to select the optimal model using the smallest value.
## The final values used for the model were sigma = 0.01466014 and C = 16.
svmpred_chemical <- predict(svmModel_chemical,  newdata = X_test)
svmEval_chemical<-postResample(svmpred_chemical,Y_test)
svmEval_chemical
##      RMSE  Rsquared       MAE 
## 0.1705339 0.9932473 0.1663201

KNN Model:

knnModel_chemical <- train(X_train,
                  Y_train,
                  method = "knn",
                  preProc = c("center", "scale"),
                  tuneLength = 10)
knnModel_chemical
## k-Nearest Neighbors 
## 
## 144 samples
##  56 predictor
## 
## Pre-processing: centered (56), scaled (56) 
## Resampling: Bootstrapped (25 reps) 
## Summary of sample sizes: 144, 144, 144, 144, 144, 144, ... 
## Resampling results across tuning parameters:
## 
##   k   RMSE      Rsquared   MAE     
##    5  1.399081  0.4141256  1.114851
##    7  1.402945  0.4173434  1.113450
##    9  1.406982  0.4159282  1.115845
##   11  1.403096  0.4199128  1.115177
##   13  1.404135  0.4241972  1.120698
##   15  1.411768  0.4221908  1.129910
##   17  1.415262  0.4238179  1.129149
##   19  1.423660  0.4210621  1.138323
##   21  1.428925  0.4233843  1.145877
##   23  1.445039  0.4141874  1.156086
## 
## RMSE was used to select the optimal model using the smallest value.
## The final value used for the model was k = 5.
knnPred_chemical <- predict(knnModel_chemical, newdata = X_test)
knnEval_chemical<-postResample(knnPred_chemical, Y_test)
knnEval_chemical
##      RMSE  Rsquared       MAE 
## 0.9699690 0.7395897 0.7470694
eval2<-cbind(nnetEval_chemical,marsEval_chemical,knnEval_chemical,svmEval_chemical)
eval2<-data.frame(eval2)
colnames(eval2)<-c('Neural Network','MARS','KNN','SVM')
eval2

SVM Model give out the best performance with 0.007721307 of RMSE and 0.999981598 of Rsquared .

b.

Which predictors are most important in the optimal nonlinear regression model? Do either the biological or process variables dominate the list? How do the top ten important predictors compare to the top ten predictors from the optimal linear model?

varImp(svmModel_chemical)
## loess r-squared variable importance
## 
##   only 20 most important variables shown (out of 56)
## 
##                        Overall
## ManufacturingProcess32  100.00
## BiologicalMaterial06     89.04
## ManufacturingProcess13   85.75
## BiologicalMaterial03     73.17
## BiologicalMaterial12     66.20
## ManufacturingProcess36   65.62
## ManufacturingProcess09   63.19
## ManufacturingProcess17   60.35
## ManufacturingProcess31   57.55
## BiologicalMaterial02     56.91
## ManufacturingProcess06   51.64
## ManufacturingProcess29   49.75
## ManufacturingProcess11   49.48
## ManufacturingProcess33   47.11
## BiologicalMaterial04     44.69
## ManufacturingProcess30   41.94
## BiologicalMaterial11     41.68
## BiologicalMaterial09     41.07
## BiologicalMaterial01     39.32
## BiologicalMaterial08     37.21

The most important predictor is ManufacturingProcess32. For the top ten most important variables, process variables account for seven, so we can say process variables dominate the list. Comparing to the top 10 predictors from the PLS model (we showed the list in question 6.3 before. https://rpubs.com/DaisyCai/Data624_HW7), the name of the predictor variables are similar except some minor changes of the order. For example, BiologicalMaterial06 is the 7th most important variable on the list of pls model, but it become the second most important variable when we use SVM model.

c.

Explore the relationships between the top predictors and the response for the predictors that are unique to the optimal nonlinear regression model.Do these plots reveal intuition about the biological or process predictors and their relationship with yield?

I choose the top 5 most important variables to explore the relationship between predictors and response.

chemical%>%
       select(c('Yield','ManufacturingProcess32','BiologicalMaterial06','ManufacturingProcess09',
                'ManufacturingProcess13','ManufacturingProcess36'))%>%
       cor()
##                             Yield ManufacturingProcess32
## Yield                   1.0000000             0.60833215
## ManufacturingProcess32  0.6083321             1.00000000
## BiologicalMaterial06    0.4781634             0.60059580
## ManufacturingProcess09  0.5034705             0.04100301
## ManufacturingProcess13 -0.5036797            -0.10120679
## ManufacturingProcess36 -0.5257340            -0.78800943
##                        BiologicalMaterial06 ManufacturingProcess09
## Yield                             0.4781634             0.50347051
## ManufacturingProcess32            0.6005958             0.04100301
## BiologicalMaterial06              1.0000000             0.23005968
## ManufacturingProcess09            0.2300597             1.00000000
## ManufacturingProcess13           -0.1218676            -0.79135366
## ManufacturingProcess36           -0.5304800            -0.05005281
##                        ManufacturingProcess13 ManufacturingProcess36
## Yield                              -0.5036797            -0.52573401
## ManufacturingProcess32             -0.1012068            -0.78800943
## BiologicalMaterial06               -0.1218676            -0.53048003
## ManufacturingProcess09             -0.7913537            -0.05005281
## ManufacturingProcess13              1.0000000             0.09558950
## ManufacturingProcess36              0.0955895             1.00000000
value <- c('ManufacturingProcess32','BiologicalMaterial06',
             'ManufacturingProcess09','ManufacturingProcess13',
             'ManufacturingProcess36')

featurePlot(X_train[,value], Y_train)

We can see from the table, as well as the plot, ManufacturingProcess13 and ManufacturingProcess36 have negative correlation with the response. ManufacturingProcess32 has the highest positive correlation with the response yield. In addition, we detect that ManufacturingProcess32 and ManufacturingProcess36 has a very high negative correlation, -0.78800943.