Information Technology Reference
In-Depth Information
Appendix: Sample Snap Code for Machine Learning Classi
er
Used by Software Fault Data Set of Billing System
## A Test Classi
er
x<
rnorm(100, mean = 5)
probplot(x)
## the same with horizontal tickmarks at the y-axis
opar <
-
par(
las
)
-
par(las = 1)
probplot(x)
## this should show the lack of
fit at the tails
probplot(x,
)
## for increasing degrees of freedom the t-distribution converges to rbridge
## normal
probplot(x, qt, df = 1) probplot(x, qt, df = 3) probplot(x, qt, df = 10)
probplot(x, qt, df = 100) ## manually add the line through the quartiles
p<
qunif
probplot(x, line = FALSE)
lines(p, col =
-
, lty = 2, lwd = 2)
## Make the line at prob = 0.5 red
lines(p, h = 0.5, col =
green
)
### The following use the estimated distribution given by the green
### line:
## What is the probability that x is smaller than 7?
lines(p, v = 7, bend = TRUE, col =
red
blue
)
## Median and 90lines(p, h = 0.5, col =
red
, lwd = 3, bend = TRUE)
lines(p, h = c(0.05, 0.95), col =
red
, lwd = 2, lty = 3, bend = TRUE)
par(opar)
attach(Sample data Set)
## classification mode
# default with factor response:
model <
., data = iris)
# alternatively the traditional interface:
x<
svm(Species
-
*
subset(iris, select =
Species)
-
y<
Species
model <
-
svm(x, y)
print(model)
summary(model)
# test with train data
pred <
-
predict(model, x)
# (same as:)
pred <
-
-
fitted(model)
Search WWH ::




Custom Search