DATA 624 Homework 7

Question 6.2

Developing a model to predict permeability (see Sect. 1.4) could save significant resources for a pharmaceutical company, while at the same time more rapidly identifying molecules that have a sufficient permeability to become a drug:

Start R and use these commands to load the data:

The fingerprint predictors indicate the presence or absence of substructures of a molecule and are often sparse meaning that relatively few of the molecules contain each substructure. Filter out the predictors that have low frequencies using the nearZeroVar function from the caret package. How many predictors are left for modeling?

## [1] "Total predictors: 1107"

This statement will return features that have more than one unique value

## [1] "Non-Sparse predictors: 388"

Predict the response for the test set. What is the test set estimate of R2?

The R-squared on the test set is .3

##              Model     RMSE  Rsquared
## permeability   PLS 13.23639 0.3016825

##Try building other models discussed in this chapter. Do any have better predictive performance?

## Loading required package: lars
## Loaded lars 1.2
## Warning: package 'glmnet' was built under R version 3.6.2
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following object is masked from 'package:tidyr':
## 
##     expand
## Loaded glmnet 3.0-2
##              Model     RMSE   Rsquared
## permeability   PCR 15.90717 0.03445949
##                         Model     RMSE  Rsquared
## permeability Ridge Regression 14.59042 0.1426659
##                         Model     RMSE  Rsquared
## permeability Lasso Regression 13.98552 0.2417885
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
## There were missing values in resampled performance measures.
##                               Model     RMSE  Rsquared
## permeability Elastic Net Regression 14.08593 0.2055749

As far as R-squared values go no other method improved upon the results from the partial least squares model

Would you recommend any of your models to replace the permeability laboratory experiment?

No with the best r-squared be around .3 I do not think this would be a good idea as the model is not very good at explaining permeability

Question 6.3

A chemical manufacturing process for a pharmaceutical produce was discussed in Sect. 1.4. In this problem, the objective is to understand the relationship between biological measurement of the raw materials (predictors), measurements of the manufacutring process (predictors), and the response of product yield. Biological predictors cannot be changed but can be used to assess the quality of the raw materials before processing. On the other hand, manufacturing process predictors can be changed in the manufacturing process. Improving product yield by 1% will boot revenue by approximately one hundred thousand dollars per batch:

Start R and use these commands to load the data:

## Warning: package 'RANN' was built under R version 3.6.3

the matrix processPredictors contains the 57 predictors (12 describing the input biological material and 45 describing the process predictors) for the 176 manufacturing runs, yield contains the percent yueld for each run.

A small percentage of cells in the predictor set contain missing values. Use

an imputation function to fill in these missing values (e.g., see Sect. 3.8).

Predict the response for the test set. What is the value of the performance metric and how does this compare with the resampled performance metric on the training set?

##        RMSE  Rsquared
## 1 0.6595847 0.6534918

2020-04-05