This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
library(C50)
## Warning: package 'C50' was built under R version 4.0.5
library(rpart)
## Warning: package 'rpart' was built under R version 4.0.5
library(rpart.plot)
## Warning: package 'rpart.plot' was built under R version 4.0.5
library(gmodels)
## Warning: package 'gmodels' was built under R version 4.1.3
Resin_Train <- read.csv("C:/Users/sgujje-c/OneDrive - Takeda/L-Shire/Downloads/MLTraining.csv", header=TRUE)
Resin_Test <- read.csv("C:/Users/sgujje-c/OneDrive - Takeda/L-Shire/Downloads/MLTest.csv", header=TRUE)
Resin_Train$TreeSite = as.factor(Resin_Train$TreeSite)
Resin_Train$resinquality = as.factor(Resin_Train$resinquality)
Resin_Test$TreeSite = as.factor(Resin_Test$TreeSite)
Resin_Test$resinquality = as.factor(Resin_Test$resinquality)
#decision tree model with c50
resin_model1 = C5.0(x=Resin_Train[1:38],y=Resin_Train$resinquality)
summary(resin_model1)
##
## Call:
## C5.0.default(x = Resin_Train[1:38], y = Resin_Train$resinquality)
##
##
## C5.0 [Release 2.07 GPL Edition] Thu Apr 21 15:21:10 2022
## -------------------------------
##
## Class specified by attribute `outcome'
##
## Read 270 cases (39 attributes) from undefined.data
##
## Decision tree:
##
## Step8.resin <= 63.6:
## :...Step8.resin > 54.6: Good (168/7)
## : Step8.resin <= 54.6:
## : :...Step5.temp > 18: Bad (33/1)
## : Step5.temp <= 18:
## : :...Pressure <= 0: Good (3)
## : Pressure > 0: Bad (3)
## Step8.resin > 63.6:
## :...Step5.yield <= 79:
## :...Step2.pH <= 5.6: VeryGood (3)
## : Step2.pH > 5.6: Good (5/1)
## Step5.yield > 79:
## :...Step.1.pH > 7.230435: Good (3/1)
## Step.1.pH <= 7.230435:
## :...Step7.resin > 66.9: VeryGood (45)
## Step7.resin <= 66.9:
## :...Step7.symmetry <= 1.65: Good (3)
## Step7.symmetry > 1.65: VeryGood (4)
##
##
## Evaluation on training data (270 cases):
##
## Decision Tree
## ----------------
## Size Errors
##
## 10 10( 3.7%) <<
##
##
## (a) (b) (c) <-classified as
## ---- ---- ----
## 35 4 (a): class Bad
## 1 173 (b): class Good
## 5 52 (c): class VeryGood
##
##
## Attribute usage:
##
## 100.00% Step8.resin
## 23.33% Step5.yield
## 20.37% Step.1.pH
## 19.26% Step7.resin
## 14.44% Step5.temp
## 2.96% Step2.pH
## 2.59% Step7.symmetry
## 2.22% Pressure
##
##
## Time: 0.0 secs
resin_pred = predict(resin_model1,Resin_Test)
CrossTable(Resin_Test$resinquality,resin_pred,prop.chisq = FALSE, prop.c = FALSE, prop.r = FALSE, dnn = c('ActualResin','PredictedResin'))
##
##
## Cell Contents
## |-------------------------|
## | N |
## | N / Table Total |
## |-------------------------|
##
##
## Total Observations in Table: 70
##
##
## | PredictedResin
## ActualResin | Bad | Good | VeryGood | Row Total |
## -------------|-----------|-----------|-----------|-----------|
## Bad | 9 | 1 | 0 | 10 |
## | 0.129 | 0.014 | 0.000 | |
## -------------|-----------|-----------|-----------|-----------|
## Good | 0 | 44 | 1 | 45 |
## | 0.000 | 0.629 | 0.014 | |
## -------------|-----------|-----------|-----------|-----------|
## VeryGood | 0 | 3 | 12 | 15 |
## | 0.000 | 0.043 | 0.171 | |
## -------------|-----------|-----------|-----------|-----------|
## Column Total | 9 | 48 | 13 | 70 |
## -------------|-----------|-----------|-----------|-----------|
##
##
(p <- table(resin_pred,Resin_Test$resinquality))
##
## resin_pred Bad Good VeryGood
## Bad 9 0 0
## Good 1 44 3
## VeryGood 0 1 12
(accuracy <- sum(diag(p))/sum(p)*100)
## [1] 92.85714
#decision tree model with rpart
rpartdata = Resin_Train[1:38]
rpartmodel <- rpart(Resin_Train$resinquality~., data=rpartdata, cp=.02)
summary(rpartmodel)
## Call:
## rpart(formula = Resin_Train$resinquality ~ ., data = rpartdata,
## cp = 0.02)
## n= 270
##
## CP nsplit rel error xerror xstd
## 1 0.46875000 0 1.0000000 1.0000000 0.08193267
## 2 0.32291667 1 0.5312500 0.5416667 0.06749581
## 3 0.02083333 2 0.2083333 0.2291667 0.04682568
## 4 0.02000000 3 0.1875000 0.2500000 0.04871022
##
## Variable importance
## Step8.resin Step7.resin Step5.resin Step1.Resin
## 43 29 14 4
## Step0.return.flow Step0.tmpressure step0.output.pH Step2.Conductivity
## 2 2 2 1
## Step3.compression Step7.UV
## 1 1
##
## Node number 1: 270 observations, complexity param=0.46875
## predicted class=Good expected loss=0.3555556 P(node) =1
## class counts: 39 174 57
## probabilities: 0.144 0.644 0.211
## left son=2 (207 obs) right son=3 (63 obs)
## Primary splits:
## Step8.resin < 63.75 to the left, improve=56.68447, (0 missing)
## Step7.resin < 56.1 to the left, improve=35.17583, (0 missing)
## Step5.resin < 142.35 to the left, improve=18.87840, (0 missing)
## TreeSite splits as LLR, improve=13.46205, (0 missing)
## step0.output.pH < 7.289827 to the left, improve= 9.43372, (0 missing)
## Surrogate splits:
## Step7.resin < 66.75 to the left, agree=0.907, adj=0.603, (0 split)
## Step5.resin < 159.15 to the left, agree=0.830, adj=0.270, (0 split)
## Step0.return.flow < 79.38854 to the right, agree=0.789, adj=0.095, (0 split)
## step0.output.pH < 7.340588 to the left, agree=0.785, adj=0.079, (0 split)
## Step2.Conductivity < 46.5 to the right, agree=0.781, adj=0.063, (0 split)
##
## Node number 2: 207 observations, complexity param=0.3229167
## predicted class=Good expected loss=0.2028986 P(node) =0.7666667
## class counts: 39 165 3
## probabilities: 0.188 0.797 0.014
## left son=4 (39 obs) right son=5 (168 obs)
## Primary splits:
## Step8.resin < 54.65 to the left, improve=47.347950, (0 missing)
## Step7.resin < 56.1 to the left, improve=39.977240, (0 missing)
## Step5.resin < 142.35 to the left, improve=20.897270, (0 missing)
## Step1.Resin < 12557.7 to the left, improve= 8.739130, (0 missing)
## step0.output.pH < 7.254342 to the left, improve= 7.136339, (0 missing)
## Surrogate splits:
## Step7.resin < 55.7 to the left, agree=0.957, adj=0.769, (0 split)
## Step5.resin < 135.45 to the left, agree=0.889, adj=0.410, (0 split)
## Step1.Resin < 11678.15 to the left, agree=0.831, adj=0.103, (0 split)
## Step0.tmpressure < 11.17406 to the left, agree=0.831, adj=0.103, (0 split)
## Step3.compression < 1.255 to the right, agree=0.821, adj=0.051, (0 split)
##
## Node number 3: 63 observations, complexity param=0.02083333
## predicted class=VeryGood expected loss=0.1428571 P(node) =0.2333333
## class counts: 0 9 54
## probabilities: 0.000 0.143 0.857
## left son=6 (8 obs) right son=7 (55 obs)
## Primary splits:
## Step1.Resin < 15089.85 to the right, improve=4.260390, (0 missing)
## step0.output.pH < 7.288104 to the left, improve=3.032345, (0 missing)
## Step5.yield < 79.5 to the left, improve=2.337662, (0 missing)
## Step5.resin < 159.6 to the left, improve=2.193277, (0 missing)
## Step7.resin < 69.8 to the left, improve=2.057143, (0 missing)
## Surrogate splits:
## Step7.UV < 3.054 to the right, agree=0.921, adj=0.375, (0 split)
## Raw.Resin < 15407.5 to the right, agree=0.905, adj=0.250, (0 split)
## Step7.resin < 78.15 to the right, agree=0.889, adj=0.125, (0 split)
## Step0.return.flow < 76.94607 to the left, agree=0.889, adj=0.125, (0 split)
##
## Node number 4: 39 observations
## predicted class=Bad expected loss=0.1025641 P(node) =0.1444444
## class counts: 35 4 0
## probabilities: 0.897 0.103 0.000
##
## Node number 5: 168 observations
## predicted class=Good expected loss=0.04166667 P(node) =0.6222222
## class counts: 4 161 3
## probabilities: 0.024 0.958 0.018
##
## Node number 6: 8 observations
## predicted class=Good expected loss=0.375 P(node) =0.02962963
## class counts: 0 5 3
## probabilities: 0.000 0.625 0.375
##
## Node number 7: 55 observations
## predicted class=VeryGood expected loss=0.07272727 P(node) =0.2037037
## class counts: 0 4 51
## probabilities: 0.000 0.073 0.927
rpart.plot(rpartmodel,box.palette="RdBu", shadow.col="gray", nn=TRUE)
# Random Forest Model
library(randomForest)
## randomForest 4.6-12
## Type rfNews() to see new features/changes/bug fixes.
random_resin <- randomForest(resinquality~.,data=Resin_Train)
summary(random_resin)
## Length Class Mode
## call 3 -none- call
## type 1 -none- character
## predicted 270 factor numeric
## err.rate 2000 -none- numeric
## confusion 12 -none- numeric
## votes 810 matrix numeric
## oob.times 270 -none- numeric
## classes 3 -none- character
## importance 39 -none- numeric
## importanceSD 0 -none- NULL
## localImportance 0 -none- NULL
## proximity 0 -none- NULL
## ntree 1 -none- numeric
## mtry 1 -none- numeric
## forest 14 -none- list
## y 270 factor numeric
## test 0 -none- NULL
## inbag 0 -none- NULL
## terms 3 terms call
random_pred <- predict(random_resin,Resin_Test)
(pr<-table(random_pred,Resin_Test$resinquality))
##
## random_pred Bad Good VeryGood
## Bad 10 0 0
## Good 0 45 1
## VeryGood 0 0 14
(randaccuracy <-sum(diag(pr))/sum(pr)*100)
## [1] 98.57143
random_resin
##
## Call:
## randomForest(formula = resinquality ~ ., data = Resin_Train)
## Type of random forest: classification
## Number of trees: 500
## No. of variables tried at each split: 6
##
## OOB estimate of error rate: 4.07%
## Confusion matrix:
## Bad Good VeryGood class.error
## Bad 34 5 0 0.12820513
## Good 2 171 1 0.01724138
## VeryGood 0 3 54 0.05263158
importance(random_resin)
## MeanDecreaseGini
## TreeSite 2.3254061
## Raw.Resin 1.7566733
## Pressure 0.5473583
## Step1.Temp 0.0000000
## Step1.conductivity 1.0136366
## Step1.Resin 2.4442743
## Step2.pH 0.8566660
## Step2.Conductivity 0.9919880
## Step2.Yield 0.2521489
## Step3.Temp 0.3914166
## Step3.pH 0.8258430
## Step3.Conductivity 0.1341577
## Step3.yield 1.2470718
## Step3.compression 0.8767461
## Step4.pH 1.0256997
## Step5.resin 9.9895573
## Step5.yield 2.3914117
## Step5.temp 0.2176278
## Step6.pH.start 0.5828533
## Step6.Conductivity.start 1.1026004
## Step6.temperature 0.6365650
## Step7.symmetry 0.5974303
## Step7.resin 19.7735667
## Step8.temperature 0.4781910
## Step8.resin 27.0950320
## step.8.yield 0.4629674
## Step7.UV 1.0272475
## Step8.UV 1.3725887
## Step.1.pH 1.0844191
## step.1.particles 0.9268175
## step.1.quality. 1.7890999
## step0.total.particles 1.0859496
## step0.warmup.hrs 0.4976904
## step0.input.pH 0.8912145
## step0.output.pH 2.6239819
## Step0.tmpressure 1.9007953
## Step0.return.flow 1.4487486
## Step0.temperature 1.6501638
## Final.Resin.Product 46.0005419
order(importance(random_resin))
## [1] 4 12 18 9 10 26 24 33 3 19 22 21 11 7 14 34 30 8 5 15 27 29 32 20 13
## [26] 28 37 38 2 31 36 1 17 6 35 16 23 25 39
importance(random_resin)[order(importance(random_resin)),]
## Step1.Temp Step3.Conductivity Step5.temp
## 0.0000000 0.1341577 0.2176278
## Step2.Yield Step3.Temp step.8.yield
## 0.2521489 0.3914166 0.4629674
## Step8.temperature step0.warmup.hrs Pressure
## 0.4781910 0.4976904 0.5473583
## Step6.pH.start Step7.symmetry Step6.temperature
## 0.5828533 0.5974303 0.6365650
## Step3.pH Step2.pH Step3.compression
## 0.8258430 0.8566660 0.8767461
## step0.input.pH step.1.particles Step2.Conductivity
## 0.8912145 0.9268175 0.9919880
## Step1.conductivity Step4.pH Step7.UV
## 1.0136366 1.0256997 1.0272475
## Step.1.pH step0.total.particles Step6.Conductivity.start
## 1.0844191 1.0859496 1.1026004
## Step3.yield Step8.UV Step0.return.flow
## 1.2470718 1.3725887 1.4487486
## Step0.temperature Raw.Resin step.1.quality.
## 1.6501638 1.7566733 1.7890999
## Step0.tmpressure TreeSite Step5.yield
## 1.9007953 2.3254061 2.3914117
## Step1.Resin step0.output.pH Step5.resin
## 2.4442743 2.6239819 9.9895573
## Step7.resin Step8.resin Final.Resin.Product
## 19.7735667 27.0950320 46.0005419
##Modifying data to remove Resin quantity variables because the resin quantity has direct correlation with the final quality
resin2_train = subset(Resin_Train,select = -c(Final.Resin.Product,Raw.Resin,Step1.Resin,Step5.resin,Step7.resin,Step8.resin))
resin2_test = subset(Resin_Test,select = -c(Final.Resin.Product,Raw.Resin,Step1.Resin,Step5.resin,Step7.resin,Step8.resin))
str(resin2_test)
## 'data.frame': 70 obs. of 34 variables:
## $ TreeSite : Factor w/ 3 levels "City Harvest",..: 3 1 1 2 2 3 3 3 1 3 ...
## $ Pressure : num 0 1 3 0 1 ...
## $ Step1.Temp : int 18 18 18 18 18 18 18 18 18 18 ...
## $ Step1.conductivity : num 13.6 13.6 13.4 13.5 13.4 13.4 13.6 13.3 13.5 13.5 ...
## $ Step2.pH : num 5.66 5.64 5.62 5.65 5.6 5.6 5.63 5.63 5.63 5.63 ...
## $ Step2.Conductivity : int 50 48 48 46 47 47 50 49 49 46 ...
## $ Step2.Yield : int 8 9 9 9 8 7 8 8 7 9 ...
## $ Step3.Temp : num 19.7 19 20 19.7 19.7 ...
## $ Step3.pH : num 5.67 5.67 5.65 5.7 5.64 5.65 5.7 5.69 5.67 5.69 ...
## $ Step3.Conductivity : int 40 40 40 40 40 40 42 40 40 40 ...
## $ Step3.yield : int 19 16 15 16 19 16 19 16 16 17 ...
## $ Step3.compression : num 1.16 1.18 1.12 1.18 1.12 ...
## $ Step4.pH : num 7.1 6.44 7.42 6.53 6.43 7.9 7.44 7.59 7.71 5.89 ...
## $ Step5.yield : num 81 78 80 82 83 82 80 83 82 82 ...
## $ Step5.temp : num 19 20 19 18 19 20 20 20 19 20 ...
## $ Step6.pH.start : num 4.6 4.69 4.64 4.65 4.68 4.61 4.69 4.63 4.66 4.62 ...
## $ Step6.Conductivity.start: num 102 104 106 104 104 ...
## $ Step6.temperature : int 17 18 18 17 18 18 18 17 18 17 ...
## $ Step7.symmetry : num 1.87 1.47 1.52 1.06 1.61 1.65 1.52 1.69 1.87 1.06 ...
## $ Step8.temperature : num 18.5 19 18.5 18.5 18.5 ...
## $ step.8.yield : int 91 92 92 92 93 91 91 92 91 92 ...
## $ Step7.UV : num 3.01 3.04 2.99 3.02 2.97 ...
## $ Step8.UV : num 0.714 0.72 0.716 0.683 0.712 ...
## $ Step.1.pH : num 7.3 7.22 7.1 7.2 7.18 ...
## $ step.1.particles : num 2710000 3195667 2630000 2955714 3594242 ...
## $ step.1.quality. : num 94.2 86.7 91 93.1 94.4 ...
## $ step0.total.particles : num 930000 958733 1080000 920275 868042 ...
## $ step0.warmup.hrs : num 17 16.9 16.9 16.9 17.7 ...
## $ step0.input.pH : num 7.2 7.16 7.1 7.21 7.18 ...
## $ step0.output.pH : num 7.31 7.27 7.24 7.27 7.28 ...
## $ Step0.tmpressure : num 14.8 16.3 12.6 14.9 15.1 ...
## $ Step0.return.flow : num 81.1 81.9 81.9 81.9 80.9 ...
## $ Step0.temperature : num 9.93 10.12 10.12 9.91 10.11 ...
## $ resinquality : Factor w/ 3 levels "Bad","Good","VeryGood": 2 1 2 2 3 2 2 3 2 3 ...
str(resin2_train)
## 'data.frame': 270 obs. of 34 variables:
## $ TreeSite : Factor w/ 3 levels "City Harvest",..: 3 1 3 2 3 3 2 3 1 3 ...
## $ Pressure : num 5 6 1 1 1 1 1 1 5 2 ...
## $ Step1.Temp : int 18 18 18 18 18 18 18 18 18 18 ...
## $ Step1.conductivity : num 13.2 12.7 13.3 13.6 13.1 13.4 11.4 13.3 13.6 13.4 ...
## $ Step2.pH : num 5.6 5.67 5.65 5.63 5.62 5.65 5.62 5.6 5.63 5.59 ...
## $ Step2.Conductivity : int 48 49 48 48 46 50 49 45 48 48 ...
## $ Step2.Yield : int 7 8 9 9 8 8 8 9 8 8 ...
## $ Step3.Temp : num 19 19 19.7 21 19 ...
## $ Step3.pH : num 5.67 5.63 5.63 5.67 5.69 5.66 5.61 5.65 5.67 5.67 ...
## $ Step3.Conductivity : int 39 41 40 40 41 40 40 40 40 40 ...
## $ Step3.yield : int 17 19 17 16 19 17 16 17 16 16 ...
## $ Step3.compression : num 1.2 1.25 1.16 1.12 1.16 ...
## $ Step4.pH : num 7.32 7.99 6.5 6.17 6.85 6.96 4.81 7.68 6.36 6.85 ...
## $ Step5.yield : num 82 81 84 81 81 80 79 78 80 78 ...
## $ Step5.temp : num 17 19 19 20 20 19 19 19 20 19 ...
## $ Step6.pH.start : num 4.64 4.68 4.64 4.69 4.67 4.67 4.67 4.7 4.64 4.64 ...
## $ Step6.Conductivity.start: num 101 107 105 106 105 ...
## $ Step6.temperature : int 17 18 18 18 18 18 17 18 18 18 ...
## $ Step7.symmetry : num 1.64 1.46 1.41 1.65 1.73 1.69 1.12 1.06 1.8 1.52 ...
## $ Step8.temperature : num 18 18.5 18.5 18.5 18.5 ...
## $ step.8.yield : int 90 90 93 92 92 93 91 93 92 92 ...
## $ Step7.UV : num 3.06 2.98 3 2.95 2.98 ...
## $ Step8.UV : num 0.703 0.707 0.694 0.72 0.705 ...
## $ Step.1.pH : num 7.2 7.14 7.1 7.12 7.18 ...
## $ step.1.particles : num 3890000 3048710 2650000 3697273 3110000 ...
## $ step.1.quality. : num 88.4 91.3 90.8 93 95.9 ...
## $ step0.total.particles : num 940000 973036 890000 964320 860000 ...
## $ step0.warmup.hrs : num 17 16.9 20 16 16 ...
## $ step0.input.pH : num 7.2 7.24 7.1 7.18 7.2 ...
## $ step0.output.pH : num 7.38 7.26 7.3 7.26 7.3 ...
## $ Step0.tmpressure : num 14.8 12 14.5 15.5 13.9 ...
## $ Step0.return.flow : num 78.8 81.9 82.1 80.3 83.1 ...
## $ Step0.temperature : num 21.27 10.12 10 10 9.66 ...
## $ resinquality : Factor w/ 3 levels "Bad","Good","VeryGood": 3 2 2 3 3 3 2 3 1 2 ...
##Re-running the decision tree and random forest models with modified data
#revised decision tree model with rpart
rpartmodel2 <- rpart(resinquality~., data=resin2_train, cp=.02)
summary(rpartmodel2)
## Call:
## rpart(formula = resinquality ~ ., data = resin2_train, cp = 0.02)
## n= 270
##
## CP nsplit rel error xerror xstd
## 1 0.04687500 0 1.0000000 1.0000000 0.08193267
## 2 0.04166667 4 0.7812500 1.0416667 0.08265542
## 3 0.02604167 6 0.6979167 1.0937500 0.08344177
## 4 0.02430556 8 0.6458333 1.0416667 0.08265542
## 5 0.02000000 11 0.5729167 0.9895833 0.08173870
##
## Variable importance
## step.1.quality. step0.output.pH TreeSite
## 15 13 11
## Step0.return.flow Step.1.pH Step2.Conductivity
## 8 8 8
## Step0.temperature step0.total.particles Step5.yield
## 7 4 3
## Step6.pH.start Step7.UV Step6.Conductivity.start
## 2 2 2
## Pressure Step4.pH Step1.conductivity
## 2 2 2
## Step3.compression Step0.tmpressure Step3.Temp
## 1 1 1
## Step7.symmetry step.1.particles Step8.UV
## 1 1 1
## Step5.temp Step8.temperature step0.input.pH
## 1 1 1
##
## Node number 1: 270 observations, complexity param=0.046875
## predicted class=Good expected loss=0.3555556 P(node) =1
## class counts: 39 174 57
## probabilities: 0.144 0.644 0.211
## left son=2 (157 obs) right son=3 (113 obs)
## Primary splits:
## TreeSite splits as LLR, improve=13.462050, (0 missing)
## step0.output.pH < 7.289827 to the left, improve= 9.433720, (0 missing)
## Step5.yield < 82.5 to the left, improve= 7.561702, (0 missing)
## Step0.temperature < 10.1053 to the right, improve= 7.355880, (0 missing)
## Step0.return.flow < 81.84816 to the right, improve= 6.775569, (0 missing)
## Surrogate splits:
## step0.output.pH < 7.298438 to the left, agree=0.911, adj=0.788, (0 split)
## Step0.temperature < 10.11254 to the right, agree=0.763, adj=0.434, (0 split)
## Step.1.pH < 7.198438 to the left, agree=0.744, adj=0.389, (0 split)
## step.1.quality. < 93.51966 to the left, agree=0.730, adj=0.354, (0 split)
## Step0.return.flow < 81.90516 to the right, agree=0.722, adj=0.336, (0 split)
##
## Node number 2: 157 observations, complexity param=0.04166667
## predicted class=Good expected loss=0.2929936 P(node) =0.5814815
## class counts: 37 111 9
## probabilities: 0.236 0.707 0.057
## left son=4 (29 obs) right son=5 (128 obs)
## Primary splits:
## step.1.quality. < 88.07938 to the left, improve=4.725741, (0 missing)
## step0.output.pH < 7.254342 to the left, improve=3.872036, (0 missing)
## step0.total.particles < 929925.6 to the left, improve=2.861911, (0 missing)
## Step0.tmpressure < 15.41522 to the right, improve=2.561829, (0 missing)
## Step3.yield < 15.5 to the left, improve=2.207146, (0 missing)
## Surrogate splits:
## Step8.UV < 0.68595 to the left, agree=0.828, adj=0.069, (0 split)
## Step3.compression < 1.255 to the right, agree=0.822, adj=0.034, (0 split)
## Step0.tmpressure < 11.09952 to the left, agree=0.822, adj=0.034, (0 split)
##
## Node number 3: 113 observations, complexity param=0.046875
## predicted class=Good expected loss=0.4424779 P(node) =0.4185185
## class counts: 2 63 48
## probabilities: 0.018 0.558 0.425
## left son=6 (102 obs) right son=7 (11 obs)
## Primary splits:
## Step2.Conductivity < 46.5 to the right, improve=5.515499, (0 missing)
## step0.input.pH < 7.109916 to the left, improve=4.825102, (0 missing)
## Step7.symmetry < 1.09 to the right, improve=4.790950, (0 missing)
## Step5.yield < 83.5 to the left, improve=4.777541, (0 missing)
## Step0.temperature < 9.803226 to the right, improve=4.396180, (0 missing)
## Surrogate splits:
## Step7.symmetry < 1.09 to the right, agree=0.929, adj=0.273, (0 split)
## Step6.pH.start < 4.695 to the left, agree=0.920, adj=0.182, (0 split)
## Step8.UV < 0.73175 to the left, agree=0.920, adj=0.182, (0 split)
##
## Node number 4: 29 observations, complexity param=0.04166667
## predicted class=Bad expected loss=0.4827586 P(node) =0.1074074
## class counts: 15 14 0
## probabilities: 0.517 0.483 0.000
## left son=8 (14 obs) right son=9 (15 obs)
## Primary splits:
## Step.1.pH < 7.193649 to the left, improve=3.901806, (0 missing)
## step0.total.particles < 955275.6 to the left, improve=3.210031, (0 missing)
## step.1.quality. < 87.10625 to the right, improve=2.827997, (0 missing)
## Pressure < 0.5 to the right, improve=2.119122, (0 missing)
## Step6.Conductivity.start < 103.7105 to the right, improve=2.119122, (0 missing)
## Surrogate splits:
## Pressure < 0.5 to the right, agree=0.724, adj=0.429, (0 split)
## Step4.pH < 6.89 to the left, agree=0.724, adj=0.429, (0 split)
## Step7.UV < 2.994 to the right, agree=0.724, adj=0.429, (0 split)
## step.1.quality. < 85.57822 to the left, agree=0.690, adj=0.357, (0 split)
## step0.total.particles < 983917.3 to the left, agree=0.690, adj=0.357, (0 split)
##
## Node number 5: 128 observations, complexity param=0.02430556
## predicted class=Good expected loss=0.2421875 P(node) =0.4740741
## class counts: 22 97 9
## probabilities: 0.172 0.758 0.070
## left son=10 (44 obs) right son=11 (84 obs)
## Primary splits:
## step0.output.pH < 7.261034 to the left, improve=3.350852, (0 missing)
## Step8.UV < 0.71545 to the right, improve=2.651650, (0 missing)
## Step6.Conductivity.start < 107.1855 to the left, improve=2.611458, (0 missing)
## Step2.Conductivity < 49.5 to the left, improve=2.084535, (0 missing)
## Step5.yield < 81.5 to the left, improve=1.910175, (0 missing)
## Surrogate splits:
## Step3.compression < 1.173815 to the left, agree=0.727, adj=0.205, (0 split)
## Step6.pH.start < 4.675 to the right, agree=0.719, adj=0.182, (0 split)
## step0.input.pH < 7.103125 to the left, agree=0.719, adj=0.182, (0 split)
## step.1.quality. < 93.68387 to the right, agree=0.711, adj=0.159, (0 split)
## Step5.temp < 19.53485 to the right, agree=0.703, adj=0.136, (0 split)
##
## Node number 6: 102 observations, complexity param=0.046875
## predicted class=Good expected loss=0.3921569 P(node) =0.3777778
## class counts: 2 62 38
## probabilities: 0.020 0.608 0.373
## left son=12 (91 obs) right son=13 (11 obs)
## Primary splits:
## Step0.return.flow < 79.47473 to the right, improve=4.691074, (0 missing)
## Step5.yield < 82.5 to the left, improve=4.268567, (0 missing)
## step0.output.pH < 7.331129 to the left, improve=4.218711, (0 missing)
## Step6.Conductivity.start < 104.0045 to the right, improve=3.761283, (0 missing)
## step0.input.pH < 7.109916 to the left, improve=3.576471, (0 missing)
## Surrogate splits:
## step0.output.pH < 7.332796 to the left, agree=0.922, adj=0.273, (0 split)
## Step0.tmpressure < 12.62204 to the right, agree=0.912, adj=0.182, (0 split)
## Step0.temperature < 9.467831 to the right, agree=0.912, adj=0.182, (0 split)
## Step5.temp < 17.5 to the right, agree=0.902, adj=0.091, (0 split)
## Step6.Conductivity.start < 101.591 to the right, agree=0.902, adj=0.091, (0 split)
##
## Node number 7: 11 observations
## predicted class=VeryGood expected loss=0.09090909 P(node) =0.04074074
## class counts: 0 1 10
## probabilities: 0.000 0.091 0.909
##
## Node number 8: 14 observations
## predicted class=Bad expected loss=0.2142857 P(node) =0.05185185
## class counts: 11 3 0
## probabilities: 0.786 0.214 0.000
##
## Node number 9: 15 observations
## predicted class=Good expected loss=0.2666667 P(node) =0.05555556
## class counts: 4 11 0
## probabilities: 0.267 0.733 0.000
##
## Node number 10: 44 observations, complexity param=0.02430556
## predicted class=Good expected loss=0.3863636 P(node) =0.162963
## class counts: 15 27 2
## probabilities: 0.341 0.614 0.045
## left son=20 (26 obs) right son=21 (18 obs)
## Primary splits:
## step.1.quality. < 92.84667 to the left, improve=3.081974, (0 missing)
## Step8.UV < 0.70125 to the right, improve=2.643939, (0 missing)
## Step3.Temp < 20.5 to the left, improve=2.616162, (0 missing)
## Step3.compression < 1.188815 to the right, improve=2.112987, (0 missing)
## Pressure < 0.5 to the left, improve=1.643939, (0 missing)
## Surrogate splits:
## Step7.UV < 2.9825 to the right, agree=0.727, adj=0.333, (0 split)
## Step3.compression < 1.14 to the right, agree=0.705, adj=0.278, (0 split)
## Step4.pH < 7.355 to the left, agree=0.705, adj=0.278, (0 split)
## Step3.Temp < 19.85664 to the left, agree=0.682, adj=0.222, (0 split)
## Step8.temperature < 17.5 to the right, agree=0.682, adj=0.222, (0 split)
##
## Node number 11: 84 observations
## predicted class=Good expected loss=0.1666667 P(node) =0.3111111
## class counts: 7 70 7
## probabilities: 0.083 0.833 0.083
##
## Node number 12: 91 observations, complexity param=0.046875
## predicted class=Good expected loss=0.3406593 P(node) =0.337037
## class counts: 2 60 29
## probabilities: 0.022 0.659 0.319
## left son=24 (76 obs) right son=25 (15 obs)
## Primary splits:
## Step5.yield < 82.5 to the left, improve=4.092443, (0 missing)
## Step6.Conductivity.start < 103.7475 to the right, improve=3.366127, (0 missing)
## Step0.tmpressure < 15.28579 to the left, improve=3.149627, (0 missing)
## Step3.yield < 17.5 to the left, improve=3.064699, (0 missing)
## Step1.conductivity < 13.05 to the right, improve=2.608392, (0 missing)
## Surrogate splits:
## Step1.conductivity < 13.75 to the left, agree=0.868, adj=0.200, (0 split)
## step.8.yield < 94.5 to the left, agree=0.846, adj=0.067, (0 split)
## step0.warmup.hrs < 19.83333 to the left, agree=0.846, adj=0.067, (0 split)
## step0.output.pH < 7.294374 to the right, agree=0.846, adj=0.067, (0 split)
## Step0.tmpressure < 15.38825 to the left, agree=0.846, adj=0.067, (0 split)
##
## Node number 13: 11 observations
## predicted class=VeryGood expected loss=0.1818182 P(node) =0.04074074
## class counts: 0 2 9
## probabilities: 0.000 0.182 0.818
##
## Node number 20: 26 observations, complexity param=0.02430556
## predicted class=Bad expected loss=0.5 P(node) =0.0962963
## class counts: 13 12 1
## probabilities: 0.500 0.462 0.038
## left son=40 (18 obs) right son=41 (8 obs)
## Primary splits:
## Step2.Conductivity < 47.5 to the right, improve=3.617521, (0 missing)
## step0.total.particles < 1038950 to the left, improve=2.735107, (0 missing)
## step.1.quality. < 91.95667 to the right, improve=1.823077, (0 missing)
## Step8.UV < 0.70325 to the right, improve=1.700855, (0 missing)
## step.1.particles < 2710152 to the left, improve=1.256410, (0 missing)
## Surrogate splits:
## Step3.Temp < 20.5 to the left, agree=0.769, adj=0.250, (0 split)
## step.1.quality. < 88.676 to the right, agree=0.769, adj=0.250, (0 split)
## Pressure < 2.5 to the left, agree=0.731, adj=0.125, (0 split)
## Step2.pH < 5.655 to the left, agree=0.731, adj=0.125, (0 split)
## Step6.Conductivity.start < 107.461 to the left, agree=0.731, adj=0.125, (0 split)
##
## Node number 21: 18 observations
## predicted class=Good expected loss=0.1666667 P(node) =0.06666667
## class counts: 2 15 1
## probabilities: 0.111 0.833 0.056
##
## Node number 24: 76 observations, complexity param=0.02604167
## predicted class=Good expected loss=0.2763158 P(node) =0.2814815
## class counts: 2 55 19
## probabilities: 0.026 0.724 0.250
## left son=48 (53 obs) right son=49 (23 obs)
## Primary splits:
## step.1.quality. < 91.55882 to the right, improve=2.480873, (0 missing)
## step.1.particles < 2997250 to the left, improve=2.440958, (0 missing)
## Step1.conductivity < 13.05 to the right, improve=2.280154, (0 missing)
## Step7.UV < 3.009 to the right, improve=2.271930, (0 missing)
## step0.total.particles < 881000 to the left, improve=2.200292, (0 missing)
## Surrogate splits:
## Step0.temperature < 10.3619 to the left, agree=0.763, adj=0.217, (0 split)
## Pressure < 2.5 to the left, agree=0.750, adj=0.174, (0 split)
## step0.total.particles < 1030000 to the left, agree=0.750, adj=0.174, (0 split)
## Step0.tmpressure < 13.34409 to the right, agree=0.737, adj=0.130, (0 split)
## Step1.conductivity < 13.05 to the right, agree=0.724, adj=0.087, (0 split)
##
## Node number 25: 15 observations
## predicted class=VeryGood expected loss=0.3333333 P(node) =0.05555556
## class counts: 0 5 10
## probabilities: 0.000 0.333 0.667
##
## Node number 40: 18 observations
## predicted class=Bad expected loss=0.3333333 P(node) =0.06666667
## class counts: 12 5 1
## probabilities: 0.667 0.278 0.056
##
## Node number 41: 8 observations
## predicted class=Good expected loss=0.125 P(node) =0.02962963
## class counts: 1 7 0
## probabilities: 0.125 0.875 0.000
##
## Node number 48: 53 observations
## predicted class=Good expected loss=0.1886792 P(node) =0.1962963
## class counts: 1 43 9
## probabilities: 0.019 0.811 0.170
##
## Node number 49: 23 observations, complexity param=0.02604167
## predicted class=Good expected loss=0.4782609 P(node) =0.08518519
## class counts: 1 12 10
## probabilities: 0.043 0.522 0.435
## left son=98 (10 obs) right son=99 (13 obs)
## Primary splits:
## step0.total.particles < 880000 to the left, improve=3.409365, (0 missing)
## step.1.quality. < 88.16562 to the left, improve=3.150856, (0 missing)
## Step3.pH < 5.675 to the right, improve=2.731159, (0 missing)
## step.1.particles < 3076000 to the left, improve=2.731159, (0 missing)
## step.8.yield < 91.5 to the left, improve=2.378595, (0 missing)
## Surrogate splits:
## Step6.Conductivity.start < 105.3925 to the right, agree=0.783, adj=0.5, (0 split)
## Step6.pH.start < 4.645 to the right, agree=0.739, adj=0.4, (0 split)
## step.1.particles < 2884516 to the left, agree=0.739, adj=0.4, (0 split)
## Step0.temperature < 10.22407 to the left, agree=0.739, adj=0.4, (0 split)
## Step1.conductivity < 13.25 to the left, agree=0.696, adj=0.3, (0 split)
##
## Node number 98: 10 observations
## predicted class=Good expected loss=0.2 P(node) =0.03703704
## class counts: 1 8 1
## probabilities: 0.100 0.800 0.100
##
## Node number 99: 13 observations
## predicted class=VeryGood expected loss=0.3076923 P(node) =0.04814815
## class counts: 0 4 9
## probabilities: 0.000 0.308 0.692
rpart.plot(rpartmodel2,box.palette="RdBu", shadow.col="gray", nn=TRUE)
#Predicting c50 revised model
c50model2 = C5.0(x=resin2_train,y=resin2_train$resinquality)
summary(c50model2)
##
## Call:
## C5.0.default(x = resin2_train, y = resin2_train$resinquality)
##
##
## C5.0 [Release 2.07 GPL Edition] Thu Apr 21 15:21:16 2022
## -------------------------------
##
## Class specified by attribute `outcome'
##
## Read 270 cases (35 attributes) from undefined.data
##
## Decision tree:
##
## resinquality = Bad: Bad (39)
## resinquality = Good: Good (174)
## resinquality = VeryGood: VeryGood (57)
##
##
## Evaluation on training data (270 cases):
##
## Decision Tree
## ----------------
## Size Errors
##
## 3 0( 0.0%) <<
##
##
## (a) (b) (c) <-classified as
## ---- ---- ----
## 39 (a): class Bad
## 174 (b): class Good
## 57 (c): class VeryGood
##
##
## Attribute usage:
##
## 100.00% resinquality
##
##
## Time: 0.0 secs
c50_pred2 = predict(c50model2,resin2_test)
CrossTable(resin2_test$resinquality,c50_pred2,prop.chisq = FALSE, prop.c = FALSE, prop.r = FALSE, dnn = c('ActualResin','PredictedResin'))
##
##
## Cell Contents
## |-------------------------|
## | N |
## | N / Table Total |
## |-------------------------|
##
##
## Total Observations in Table: 70
##
##
## | PredictedResin
## ActualResin | Bad | Good | VeryGood | Row Total |
## -------------|-----------|-----------|-----------|-----------|
## Bad | 10 | 0 | 0 | 10 |
## | 0.143 | 0.000 | 0.000 | |
## -------------|-----------|-----------|-----------|-----------|
## Good | 0 | 45 | 0 | 45 |
## | 0.000 | 0.643 | 0.000 | |
## -------------|-----------|-----------|-----------|-----------|
## VeryGood | 0 | 0 | 15 | 15 |
## | 0.000 | 0.000 | 0.214 | |
## -------------|-----------|-----------|-----------|-----------|
## Column Total | 10 | 45 | 15 | 70 |
## -------------|-----------|-----------|-----------|-----------|
##
##
(pc50 <- table(c50_pred2,resin2_test$resinquality))
##
## c50_pred2 Bad Good VeryGood
## Bad 10 0 0
## Good 0 45 0
## VeryGood 0 0 15
(accuracy <- sum(diag(pc50))/sum(pc50)*100)
## [1] 100
##Re-running random forest model with modified data
library(randomForest)
random_resin2 <- randomForest(resinquality~.,data=resin2_train)
summary(random_resin2)
## Length Class Mode
## call 3 -none- call
## type 1 -none- character
## predicted 270 factor numeric
## err.rate 2000 -none- numeric
## confusion 12 -none- numeric
## votes 810 matrix numeric
## oob.times 270 -none- numeric
## classes 3 -none- character
## importance 33 -none- numeric
## importanceSD 0 -none- NULL
## localImportance 0 -none- NULL
## proximity 0 -none- NULL
## ntree 1 -none- numeric
## mtry 1 -none- numeric
## forest 14 -none- list
## y 270 factor numeric
## test 0 -none- NULL
## inbag 0 -none- NULL
## terms 3 terms call
random_pred2 <- predict(random_resin2,resin2_test)
(prn2<-table(random_pred2,resin2_test$resinquality))
##
## random_pred2 Bad Good VeryGood
## Bad 3 0 0
## Good 7 43 10
## VeryGood 0 2 5
(randaccuracy2 <-sum(diag(prn2))/sum(prn2)*100)
## [1] 72.85714
random_resin2
##
## Call:
## randomForest(formula = resinquality ~ ., data = resin2_train)
## Type of random forest: classification
## Number of trees: 500
## No. of variables tried at each split: 5
##
## OOB estimate of error rate: 28.52%
## Confusion matrix:
## Bad Good VeryGood class.error
## Bad 6 33 0 0.84615385
## Good 2 166 6 0.04597701
## VeryGood 0 36 21 0.63157895
importance(random_resin2)
## MeanDecreaseGini
## TreeSite 4.8863587
## Pressure 2.1316081
## Step1.Temp 0.0000000
## Step1.conductivity 5.1589045
## Step2.pH 3.9198526
## Step2.Conductivity 4.4288616
## Step2.Yield 1.4310085
## Step3.Temp 1.5468578
## Step3.pH 3.6727167
## Step3.Conductivity 0.7409124
## Step3.yield 4.1624469
## Step3.compression 3.4100555
## Step4.pH 5.3195574
## Step5.yield 8.1613896
## Step5.temp 1.4108599
## Step6.pH.start 3.5279449
## Step6.Conductivity.start 6.2763867
## Step6.temperature 1.6114205
## Step7.symmetry 4.5949286
## Step8.temperature 1.8728538
## step.8.yield 2.4483768
## Step7.UV 4.8560861
## Step8.UV 6.0215467
## Step.1.pH 4.6671511
## step.1.particles 5.3098165
## step.1.quality. 7.9728609
## step0.total.particles 6.1145667
## step0.warmup.hrs 2.1254898
## step0.input.pH 3.8772390
## step0.output.pH 8.8920230
## Step0.tmpressure 7.4269365
## Step0.return.flow 5.1740523
## Step0.temperature 5.9841742
order(importance(random_resin2))
## [1] 3 10 15 7 8 18 20 28 2 21 12 16 9 29 5 11 6 19 24 22 1 4 32 25 13
## [26] 33 23 27 17 31 26 14 30
importance(random_resin2)[order(importance(random_resin2)),]
## Step1.Temp Step3.Conductivity Step5.temp
## 0.0000000 0.7409124 1.4108599
## Step2.Yield Step3.Temp Step6.temperature
## 1.4310085 1.5468578 1.6114205
## Step8.temperature step0.warmup.hrs Pressure
## 1.8728538 2.1254898 2.1316081
## step.8.yield Step3.compression Step6.pH.start
## 2.4483768 3.4100555 3.5279449
## Step3.pH step0.input.pH Step2.pH
## 3.6727167 3.8772390 3.9198526
## Step3.yield Step2.Conductivity Step7.symmetry
## 4.1624469 4.4288616 4.5949286
## Step.1.pH Step7.UV TreeSite
## 4.6671511 4.8560861 4.8863587
## Step1.conductivity Step0.return.flow step.1.particles
## 5.1589045 5.1740523 5.3098165
## Step4.pH Step0.temperature Step8.UV
## 5.3195574 5.9841742 6.0215467
## step0.total.particles Step6.Conductivity.start Step0.tmpressure
## 6.1145667 6.2763867 7.4269365
## step.1.quality. Step5.yield step0.output.pH
## 7.9728609 8.1613896 8.8920230
You can also embed plots, for example:
## TreeSite Raw.Resin Pressure Step1.Temp Step1.conductivity Step1.Resin
## 1 Village Harvest 15416.00 5 18 13.2 15334.0
## 2 City Harvest 16157.00 6 18 12.7 12826.6
## 3 Village Harvest 13018.37 1 18 13.3 11882.4
## 4 Mix Harvest 14986.32 1 18 13.6 14337.7
## 5 Village Harvest 12853.80 1 18 13.1 12910.7
## 6 Village Harvest 14906.94 1 18 13.4 14696.6
## Step2.pH Step2.Conductivity Step2.Yield Step3.Temp Step3.pH
## 1 5.60 48 7 19.00000 5.67
## 2 5.67 49 8 19.00000 5.63
## 3 5.65 48 9 19.71329 5.63
## 4 5.63 48 9 21.00000 5.67
## 5 5.62 46 8 19.00000 5.69
## 6 5.65 50 8 19.71329 5.66
## Step3.Conductivity Step3.yield Step3.compression Step4.pH Step5.resin
## 1 39 17 1.20000 7.32 154.8
## 2 41 19 1.25000 7.99 148.5
## 3 40 17 1.16000 6.50 147.4
## 4 40 16 1.12000 6.17 158.7
## 5 41 19 1.16000 6.85 150.7
## 6 40 17 1.17763 6.96 164.5
## Step5.yield Step5.temp Step6.pH.start Step6.Conductivity.start
## 1 82 17 4.64 101.172
## 2 81 19 4.68 106.642
## 3 84 19 4.64 104.847
## 4 81 20 4.69 105.662
## 5 81 20 4.67 105.068
## 6 80 19 4.67 103.990
## Step6.temperature Step7.symmetry Step7.resin Step8.temperature Step8.resin
## 1 17 1.64 68.3 18.00000 64.0
## 2 18 1.46 61.4 18.54622 59.0
## 3 18 1.41 62.9 18.54622 60.6
## 4 18 1.65 68.3 18.54622 66.3
## 5 18 1.73 64.5 18.54622 65.6
## 6 18 1.69 66.8 19.00000 65.3
## step.8.yield Step7.UV Step8.UV Step.1.pH step.1.particles step.1.quality.
## 1 90 3.055 0.7029 7.200000 3890000 88.40000
## 2 90 2.983 0.7074 7.138710 3048710 91.29032
## 3 93 3.000 0.6944 7.100000 2650000 90.80000
## 4 92 2.950 0.7198 7.118182 3697273 92.98788
## 5 92 2.985 0.7053 7.182208 3110000 95.90000
## 6 93 2.960 0.7051 7.248387 3182258 93.17097
## step0.total.particles step0.warmup.hrs step0.input.pH step0.output.pH
## 1 940000.0 17.00000 7.200000 7.376667
## 2 973035.6 16.93137 7.241935 7.262069
## 3 890000.0 20.00000 7.100000 7.300000
## 4 964320.1 16.00000 7.178788 7.263636
## 5 860000.0 16.00000 7.200000 7.300000
## 6 989354.8 16.93137 7.154839 7.300000
## Step0.tmpressure Step0.return.flow Step0.temperature Final.Resin.Product
## 1 14.77778 78.83333 21.269444 65.8051
## 2 11.97097 81.90710 10.117944 60.8994
## 3 14.50000 82.10714 10.000000 60.7256
## 4 15.53333 80.33333 10.000000 66.4547
## 5 13.86207 83.13793 9.655172 66.8832
## 6 13.70968 81.90710 11.290323 65.6680
## resinquality
## 1 VeryGood
## 2 Good
## 3 Good
## 4 VeryGood
## 5 VeryGood
## 6 VeryGood
## 'data.frame': 270 obs. of 40 variables:
## $ TreeSite : Factor w/ 3 levels "City Harvest",..: 3 1 3 2 3 3 2 3 1 3 ...
## $ Raw.Resin : num 15416 16157 13018 14986 12854 ...
## $ Pressure : num 5 6 1 1 1 1 1 1 5 2 ...
## $ Step1.Temp : int 18 18 18 18 18 18 18 18 18 18 ...
## $ Step1.conductivity : num 13.2 12.7 13.3 13.6 13.1 13.4 11.4 13.3 13.6 13.4 ...
## $ Step1.Resin : num 15334 12827 11882 14338 12911 ...
## $ Step2.pH : num 5.6 5.67 5.65 5.63 5.62 5.65 5.62 5.6 5.63 5.59 ...
## $ Step2.Conductivity : int 48 49 48 48 46 50 49 45 48 48 ...
## $ Step2.Yield : int 7 8 9 9 8 8 8 9 8 8 ...
## $ Step3.Temp : num 19 19 19.7 21 19 ...
## $ Step3.pH : num 5.67 5.63 5.63 5.67 5.69 5.66 5.61 5.65 5.67 5.67 ...
## $ Step3.Conductivity : int 39 41 40 40 41 40 40 40 40 40 ...
## $ Step3.yield : int 17 19 17 16 19 17 16 17 16 16 ...
## $ Step3.compression : num 1.2 1.25 1.16 1.12 1.16 ...
## $ Step4.pH : num 7.32 7.99 6.5 6.17 6.85 6.96 4.81 7.68 6.36 6.85 ...
## $ Step5.resin : num 155 148 147 159 151 ...
## $ Step5.yield : num 82 81 84 81 81 80 79 78 80 78 ...
## $ Step5.temp : num 17 19 19 20 20 19 19 19 20 19 ...
## $ Step6.pH.start : num 4.64 4.68 4.64 4.69 4.67 4.67 4.67 4.7 4.64 4.64 ...
## $ Step6.Conductivity.start: num 101 107 105 106 105 ...
## $ Step6.temperature : int 17 18 18 18 18 18 17 18 18 18 ...
## $ Step7.symmetry : num 1.64 1.46 1.41 1.65 1.73 1.69 1.12 1.06 1.8 1.52 ...
## $ Step7.resin : num 68.3 61.4 62.9 68.3 64.5 66.8 62.1 72.6 52.6 68 ...
## $ Step8.temperature : num 18 18.5 18.5 18.5 18.5 ...
## $ Step8.resin : num 64 59 60.6 66.3 65.6 65.3 60.5 71.2 51.7 62.4 ...
## $ step.8.yield : int 90 90 93 92 92 93 91 93 92 92 ...
## $ Step7.UV : num 3.06 2.98 3 2.95 2.98 ...
## $ Step8.UV : num 0.703 0.707 0.694 0.72 0.705 ...
## $ Step.1.pH : num 7.2 7.14 7.1 7.12 7.18 ...
## $ step.1.particles : num 3890000 3048710 2650000 3697273 3110000 ...
## $ step.1.quality. : num 88.4 91.3 90.8 93 95.9 ...
## $ step0.total.particles : num 940000 973036 890000 964320 860000 ...
## $ step0.warmup.hrs : num 17 16.9 20 16 16 ...
## $ step0.input.pH : num 7.2 7.24 7.1 7.18 7.2 ...
## $ step0.output.pH : num 7.38 7.26 7.3 7.26 7.3 ...
## $ Step0.tmpressure : num 14.8 12 14.5 15.5 13.9 ...
## $ Step0.return.flow : num 78.8 81.9 82.1 80.3 83.1 ...
## $ Step0.temperature : num 21.27 10.12 10 10 9.66 ...
## $ Final.Resin.Product : num 65.8 60.9 60.7 66.5 66.9 ...
## $ resinquality : Factor w/ 3 levels "Bad","Good","VeryGood": 3 2 2 3 3 3 2 3 1 2 ...
## TreeSite Raw.Resin Pressure Step1.Temp Step1.conductivity Step1.Resin
## 1 Village Harvest 12712.50 0 18 13.6 12151.5
## 2 City Harvest 13824.90 1 18 13.6 12803.1
## 3 City Harvest 14937.10 3 18 13.4 13849.2
## 4 Mix Harvest 14527.56 0 18 13.5 13903.6
## 5 Mix Harvest 12849.85 1 18 13.4 13692.6
## 6 Village Harvest 14172.00 1 18 13.4 14680.7
## Step2.pH Step2.Conductivity Step2.Yield Step3.Temp Step3.pH
## 1 5.66 50 8 19.71329 5.67
## 2 5.64 48 9 19.00000 5.67
## 3 5.62 48 9 20.00000 5.65
## 4 5.65 46 9 19.71329 5.70
## 5 5.60 47 8 19.71329 5.64
## 6 5.60 47 7 20.00000 5.65
## Step3.Conductivity Step3.yield Step3.compression Step4.pH Step5.resin
## 1 40 19 1.16000 7.10 145.3
## 2 40 16 1.17763 6.44 139.1
## 3 40 15 1.12000 7.42 139.6
## 4 40 16 1.17763 6.53 158.7
## 5 40 19 1.12000 6.43 160.7
## 6 40 16 1.17763 7.90 143.6
## Step5.yield Step5.temp Step6.pH.start Step6.Conductivity.start
## 1 81 19 4.60 101.758
## 2 78 20 4.69 104.264
## 3 80 19 4.64 106.332
## 4 82 18 4.65 104.044
## 5 83 19 4.68 104.367
## 6 82 20 4.61 106.743
## Step6.temperature Step7.symmetry Step7.resin Step8.temperature Step8.resin
## 1 17 1.87 67.4 18.54622 67.1
## 2 18 1.47 49.4 19.00000 47.9
## 3 18 1.52 61.8 18.54622 56.6
## 4 17 1.06 64.8 18.54622 61.3
## 5 18 1.61 69.5 18.54622 68.9
## 6 18 1.65 59.4 18.54622 58.8
## step.8.yield Step7.UV Step8.UV Step.1.pH step.1.particles step.1.quality.
## 1 91 3.008 0.7136 7.300000 2710000 94.20000
## 2 92 3.038 0.7198 7.220000 3195667 86.74667
## 3 92 2.992 0.7155 7.100000 2630000 91.00000
## 4 92 3.023 0.6835 7.200000 2955714 93.09643
## 5 93 2.970 0.7124 7.181818 3594242 94.35455
## 6 91 2.982 0.7305 7.222581 4067742 92.10323
## step0.total.particles step0.warmup.hrs step0.input.pH step0.output.pH
## 1 930000.0 17.00000 7.200000 7.307692
## 2 958733.3 16.93137 7.160000 7.270833
## 3 1080000.0 16.93137 7.100000 7.235484
## 4 920274.7 16.93137 7.209677 7.267857
## 5 868042.0 17.66667 7.181818 7.278571
## 6 1159354.8 16.22581 7.200000 7.317857
## Step0.tmpressure Step0.return.flow Step0.temperature Final.Resin.Product
## 1 14.79310 81.10345 9.931034 62.9900
## 2 16.25333 81.90710 10.117944 50.0562
## 3 12.61613 81.90710 10.117944 58.0684
## 4 14.88064 81.90710 9.909091 61.0485
## 5 15.08788 80.88889 10.111111 69.7735
## 6 14.16129 80.58065 10.129032 61.6135
## resinquality
## 1 Good
## 2 Bad
## 3 Good
## 4 Good
## 5 VeryGood
## 6 Good
## 'data.frame': 70 obs. of 40 variables:
## $ TreeSite : Factor w/ 3 levels "City Harvest",..: 3 1 1 2 2 3 3 3 1 3 ...
## $ Raw.Resin : num 12712 13825 14937 14528 12850 ...
## $ Pressure : num 0 1 3 0 1 ...
## $ Step1.Temp : int 18 18 18 18 18 18 18 18 18 18 ...
## $ Step1.conductivity : num 13.6 13.6 13.4 13.5 13.4 13.4 13.6 13.3 13.5 13.5 ...
## $ Step1.Resin : num 12152 12803 13849 13904 13693 ...
## $ Step2.pH : num 5.66 5.64 5.62 5.65 5.6 5.6 5.63 5.63 5.63 5.63 ...
## $ Step2.Conductivity : int 50 48 48 46 47 47 50 49 49 46 ...
## $ Step2.Yield : int 8 9 9 9 8 7 8 8 7 9 ...
## $ Step3.Temp : num 19.7 19 20 19.7 19.7 ...
## $ Step3.pH : num 5.67 5.67 5.65 5.7 5.64 5.65 5.7 5.69 5.67 5.69 ...
## $ Step3.Conductivity : int 40 40 40 40 40 40 42 40 40 40 ...
## $ Step3.yield : int 19 16 15 16 19 16 19 16 16 17 ...
## $ Step3.compression : num 1.16 1.18 1.12 1.18 1.12 ...
## $ Step4.pH : num 7.1 6.44 7.42 6.53 6.43 7.9 7.44 7.59 7.71 5.89 ...
## $ Step5.resin : num 145 139 140 159 161 ...
## $ Step5.yield : num 81 78 80 82 83 82 80 83 82 82 ...
## $ Step5.temp : num 19 20 19 18 19 20 20 20 19 20 ...
## $ Step6.pH.start : num 4.6 4.69 4.64 4.65 4.68 4.61 4.69 4.63 4.66 4.62 ...
## $ Step6.Conductivity.start: num 102 104 106 104 104 ...
## $ Step6.temperature : int 17 18 18 17 18 18 18 17 18 17 ...
## $ Step7.symmetry : num 1.87 1.47 1.52 1.06 1.61 1.65 1.52 1.69 1.87 1.06 ...
## $ Step7.resin : num 67.4 49.4 61.8 64.8 69.5 59.4 57.3 80.4 61 78.3 ...
## $ Step8.temperature : num 18.5 19 18.5 18.5 18.5 ...
## $ Step8.resin : num 67.1 47.9 56.6 61.3 68.9 58.8 54.8 68 58.5 76.7 ...
## $ step.8.yield : int 91 92 92 92 93 91 91 92 91 92 ...
## $ Step7.UV : num 3.01 3.04 2.99 3.02 2.97 ...
## $ Step8.UV : num 0.714 0.72 0.716 0.683 0.712 ...
## $ Step.1.pH : num 7.3 7.22 7.1 7.2 7.18 ...
## $ step.1.particles : num 2710000 3195667 2630000 2955714 3594242 ...
## $ step.1.quality. : num 94.2 86.7 91 93.1 94.4 ...
## $ step0.total.particles : num 930000 958733 1080000 920275 868042 ...
## $ step0.warmup.hrs : num 17 16.9 16.9 16.9 17.7 ...
## $ step0.input.pH : num 7.2 7.16 7.1 7.21 7.18 ...
## $ step0.output.pH : num 7.31 7.27 7.24 7.27 7.28 ...
## $ Step0.tmpressure : num 14.8 16.3 12.6 14.9 15.1 ...
## $ Step0.return.flow : num 81.1 81.9 81.9 81.9 80.9 ...
## $ Step0.temperature : num 9.93 10.12 10.12 9.91 10.11 ...
## $ Final.Resin.Product : num 63 50.1 58.1 61 69.8 ...
## $ resinquality : Factor w/ 3 levels "Bad","Good","VeryGood": 2 1 2 2 3 2 2 3 2 3 ...
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.