Графический анализ данных
library(caret)
## Загрузка требуемого пакета: ggplot2
## Загрузка требуемого пакета: lattice
x <- matrix(rnorm(50*5), ncol=5)
y <- factor(rep(c("A", "B"), 25))
data <- data.frame(x, y)
featurePlot(x = data[,1:5], y = data$y, plot = "pairs")

Важность признаков
library(FSelector)
data(iris)
weights <- information.gain(Species ~ ., iris)
print(weights)
## attr_importance
## Sepal.Length 0.4521286
## Sepal.Width 0.2672750
## Petal.Length 0.9402853
## Petal.Width 0.9554360
Преобразование переменных
library(arules)
## Загрузка требуемого пакета: Matrix
##
## Присоединяю пакет: 'arules'
## Следующие объекты скрыты от 'package:base':
##
## abbreviate, write
data(iris)
iris$Sepal.Length.interval <- discretize(iris$Sepal.Length, method = "interval", categories = 3)
## Warning in discretize(iris$Sepal.Length, method = "interval", categories = 3):
## Parameter categories is deprecated. Use breaks instead! Also, the default
## method is now frequency!
iris$Sepal.Length.frequency <- discretize(iris$Sepal.Length, method = "frequency", categories = 3)
## Warning in discretize(iris$Sepal.Length, method = "frequency", categories = 3):
## Parameter categories is deprecated. Use breaks instead! Also, the default
## method is now frequency!
iris$Sepal.Length.cluster <- discretize(iris$Sepal.Length, method = "cluster", categories = 3)
## Warning in discretize(iris$Sepal.Length, method = "cluster", categories = 3):
## Parameter categories is deprecated. Use breaks instead! Also, the default
## method is now frequency!
iris$Sepal.Length.fixed <- discretize(iris$Sepal.Length, method = "fixed", categories = c(4.3, 5.8, 7.9))
## Warning in discretize(iris$Sepal.Length, method = "fixed", categories = c(4.3,
## : Parameter categories is deprecated. Use breaks instead! Also, the default
## method is now frequency!
summary(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width
## Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100
## 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300
## Median :5.800 Median :3.000 Median :4.350 Median :1.300
## Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199
## 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800
## Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500
## Species Sepal.Length.interval Sepal.Length.frequency
## setosa :50 [4.3,5.5):52 [4.3,5.4):46
## versicolor:50 [5.5,6.7):70 [5.4,6.3):53
## virginica :50 [6.7,7.9]:28 [6.3,7.9]:51
##
##
##
## Sepal.Length.cluster Sepal.Length.fixed
## [4.3,5.33) :46 [4.3,5.8):73
## [5.33,6.27):53 [5.8,7.9]:77
## [6.27,7.9] :51
##
##
##
Выбор признаков
library(Boruta)
data(mtcars)
Применение Boruta для выбора признаков
set.seed(123)
boruta_output <- Boruta(mpg ~ ., data = mtcars, doTrace = 2)
## 1. run of importance source...
## 2. run of importance source...
## 3. run of importance source...
## 4. run of importance source...
## 5. run of importance source...
## 6. run of importance source...
## 7. run of importance source...
## 8. run of importance source...
## 9. run of importance source...
## 10. run of importance source...
## After 10 iterations, +0.1 secs:
## confirmed 10 attributes: am, carb, cyl, disp, drat and 5 more;
## no more attributes left.
plot(boruta_output)

print(boruta_output)
## Boruta performed 10 iterations in 0.101815 secs.
## 10 attributes confirmed important: am, carb, cyl, disp, drat and 5
## more;
## No attributes deemed unimportant.