Blog of Applied_Predictive_Model_11_chenshuai_2004
class=”markdown_views prism-atom-one-dark”> I have been using Python/R/Shell for background development, but lack of communication. It’s the first time I try to post what I’m learning on the blog, hoping to get some guidance from the experts so that I can get some sunshine. library(AppliedPredictiveModeling) data(concrete) library(caret) library(plyr) head(concrete,2) Cement BlastFurnaceSlag FlyAsh Water Superplasticizer CoarseAggregate FineAggregate Age CompressiveStrength 540 0 0 162 2.5 1040 676 28 79.99 540 0 0 162 2.5 1055 676 28 61.89 featurePlot(concrete[, -9], concrete$CompressiveStrength, between = list(x = 1, y = 1), type = c(“g”, “p”, “smooth”)) averaged <- ddply(mixtures, .(Cement, BlastFurnaceSlag, FlyAsh, Water, Superplasticizer, Coarse Aggregate, FineAggregate, Age), function(x) c(CompressiveStrength = mean(x$CompressiveStrength))) head(mixtures,2) Cement BlastFurnaceSlag FlyAsh Water Superplasticizer CoarseAggregate FineAggregate Age CompressiveStrength 0.2230944 0 0 0.06692832 0.001032844 0.4296633 0.2792811 28 79.99 0.2217204 0 0 0.06651612 0.001026483 0.4331759 0.2775611 28 61.89 set.seed(975) inTrain <- createDataPartition(averaged$CompressiveStrength, p = 3/4)[[1]] training <- averaged[inTrain,] testing <- averaged[-inTrain,] ### Repeated Training/Test Splits ctrl <- trainControl(method = “repeatedcv”, repeats = 5, number span> = 10) ### Create a model formula that can be used repeatedly modForm <- paste(“CompressiveStrength ~ (.)^2 + I(Cement^2) + I(BlastFurnaceSlag^2) +”, “I(FlyAsh^2) + I(Water^2) + I(Superplasticizer^2) + “, “I(CoarseAggregate^2) + I(FineAggregate^2) + I(Age^2)” ) modForm <- as.formula(-…