In [ ]:
# carga de los datos
wine <- read.csv("data/whitewines.csv")
str(wine)
In [ ]:
hist(wine$quality)
In [ ]:
wine_train <- wine[1:3750, ]
wine_test <- wine[3751:4898, ]
In [1]:
install.packages("rpart")
library(rpart)
In [ ]:
m.rpart <- rpart(quality ~ ., data = wine_train)
m.rpart
In [ ]:
summary(m.rpart)
In [ ]:
install.packages("rpart.plot")
library(rpart.plot)
rpart.plot(m.rpart, digits = 3)
In [ ]:
rpart.plot(m.rpart,
digits = 4,
fallen.leaves = TRUE,
type = 3,
extra = 101)
In [ ]:
p.rpart <- predict(m.rpart, wine_test)
summary(p.rpart)
In [ ]:
summary(wine_test$quality)
In [ ]:
MAE <- function(actual, predicted) {
mean(abs(actual - predicted))
}
In [ ]:
MAE(p.rpart, wine_test$quality)
In [ ]:
mean(wine_train$quality)
In [ ]:
MAE(5.87, wine_test$quality)
In [ ]:
In [ ]:
library(RWeka)
m.m5p <- M5P(quality ~ ., data = wine_train)
m.m5p
In [ ]:
summary(m.m5p)
In [ ]:
ins_model2 <- lm(expenses ~ age + age2 + children + bmi + sex + bmi30*smoker + region,
data = insurance)
summary(ins_model2)
In [ ]:
In [ ]: