Equipment Fault Detection
Dataset
library(knitr)
data <- read.csv(file.choose())
kable(head(data))
| 3000.4 |
31.81 |
19.02 |
213.14 |
118.31 |
108.06 |
149.97 |
78.03 |
176.19 |
0.02 |
-0.02 |
1 |
| 2999.6 |
31.83 |
19.02 |
213.13 |
118.32 |
108.18 |
149.97 |
78.10 |
175.99 |
-0.04 |
-0.02 |
1 |
| 3000.4 |
31.35 |
19.02 |
213.13 |
118.08 |
107.94 |
149.97 |
77.97 |
175.76 |
0.03 |
-0.02 |
1 |
| 2998.8 |
31.77 |
19.01 |
213.12 |
118.59 |
108.45 |
149.97 |
78.18 |
176.13 |
0.05 |
-0.02 |
1 |
| 2998.0 |
31.92 |
19.01 |
213.11 |
118.83 |
108.63 |
149.97 |
78.45 |
175.95 |
0.14 |
-0.02 |
1 |
| 2999.6 |
31.84 |
19.01 |
213.11 |
118.26 |
108.06 |
149.97 |
78.02 |
175.89 |
0.02 |
-0.02 |
1 |
Data summary
library(skimr)
skim(data)
Data summary
| Name |
data |
| Number of rows |
18721 |
| Number of columns |
12 |
| _______________________ |
|
| Column type frequency: |
|
| numeric |
12 |
| ________________________ |
|
| Group variables |
None |
Variable type: numeric
| Rotation.speed |
0 |
1 |
2999.60 |
0.84 |
2996.00 |
2999.20 |
2999.60 |
3000.40 |
3002.80 |
▁▂▇▃▁ |
| Positioner1 |
0 |
1 |
45.23 |
5.73 |
29.78 |
40.71 |
48.45 |
48.64 |
51.04 |
▁▂▁▁▇ |
| Positioner2 |
0 |
1 |
30.02 |
9.06 |
18.22 |
22.51 |
27.63 |
34.11 |
52.18 |
▇▃▆▁▂ |
| Positioner3 |
0 |
1 |
211.88 |
0.94 |
209.93 |
211.26 |
211.64 |
212.37 |
215.89 |
▂▇▃▁▁ |
| Current.to.valve.1 |
0 |
1 |
136.41 |
12.25 |
116.19 |
126.21 |
130.14 |
149.67 |
149.97 |
▃▅▂▁▇ |
| Current.to.valve.2 |
0 |
1 |
124.90 |
8.74 |
106.20 |
119.81 |
122.64 |
128.40 |
149.97 |
▁▇▅▁▁ |
| Current.to.valve.3 |
0 |
1 |
149.46 |
1.05 |
144.39 |
149.95 |
149.97 |
149.97 |
149.97 |
▁▁▁▁▇ |
| Turbine.controller.output |
0 |
1 |
87.69 |
4.88 |
76.60 |
84.32 |
88.26 |
89.77 |
99.62 |
▁▂▇▁▁ |
| Power |
0 |
1 |
205.15 |
9.26 |
173.95 |
201.28 |
206.17 |
213.19 |
217.16 |
▁▁▃▇▇ |
| Power.regulator.mismatch |
0 |
1 |
0.03 |
0.22 |
-1.50 |
-0.07 |
0.00 |
0.07 |
2.22 |
▁▇▇▁▁ |
| Speed.controller.mismatch |
0 |
1 |
-0.02 |
0.02 |
-0.12 |
-0.04 |
-0.02 |
0.00 |
0.06 |
▁▂▇▆▁ |
| Mechanical.problem |
0 |
1 |
0.46 |
0.50 |
0.00 |
0.00 |
0.00 |
1.00 |
1.00 |
▇▁▁▁▇ |
Relationships
library(psych)
pairs.panels(data)

library(corrplot)
corrplot(cor(data),method="number",number.cex = 0.5,tl.cex=0.8)

Logistic regression
model1 <- glm(as.factor(Mechanical.problem)~.,family = binomial(link = "logit"),data = data)
summary(model1)
##
## Call:
## glm(formula = as.factor(Mechanical.problem) ~ ., family = binomial(link = "logit"),
## data = data)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.274 0.000 0.000 0.000 3.721
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -1.226e+05 1.244e+06 -0.099 0.921497
## Rotation.speed 4.726e-01 7.779e-01 0.607 0.543526
## Positioner1 -1.492e+00 7.677e-01 -1.944 0.051885 .
## Positioner2 3.957e-02 4.530e-01 0.087 0.930399
## Positioner3 1.403e+01 5.905e+00 2.376 0.017493 *
## Current.to.valve.1 2.425e+00 7.186e-01 3.374 0.000741 ***
## Current.to.valve.2 3.800e+00 1.493e+00 2.544 0.010944 *
## Current.to.valve.3 7.898e+02 8.292e+03 0.095 0.924119
## Turbine.controller.output -6.181e+00 2.654e+00 -2.329 0.019853 *
## Power -2.330e+00 1.042e+00 -2.235 0.025403 *
## Power.regulator.mismatch -4.092e+00 4.053e+00 -1.010 0.312712
## Speed.controller.mismatch 1.711e+01 3.705e+01 0.462 0.644241
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 25842.098 on 18720 degrees of freedom
## Residual deviance: 25.342 on 18709 degrees of freedom
## AIC: 49.342
##
## Number of Fisher Scoring iterations: 25
Prediction
pred <- predict(model1,data[,-12],type = "response")
head(pred,10)
## 1 2 3 4 5 6 7 8 9 10
## 1 1 1 1 1 1 1 1 1 1
Confusion Matrix
fault <- ifelse(pred<0.5,0,1)
head(fault)
## 1 2 3 4 5 6
## 1 1 1 1 1 1
tb <- table(fault,data$Mechanical.problem)
tb
##
## fault 0 1
## 0 10079 1
## 1 1 8640
Accuracy
mean(fault==data$Mechanical.problem)
## [1] 0.9998932