forked from joanby/machinelearning-az
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
69 lines (69 loc) · 2.54 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
install.packages("caTools")
# Plantilla para el Pre Procesado de Datos - Datos faltantes
# Importar el dataset
dataset = read.csv('Data.csv')
getwd()
setwd("~/Documents/Cursos Udemy/Matematicas/machinelearning-az/datasets/Part 1 - Data Preprocessing/Section 2 -------------------- Part 1 - Data Preprocessing --------------------")
# Plantilla para el Pre Procesado de Datos - Datos faltantes
# Importar el dataset
dataset = read.csv('Data.csv')
View(dataset)
# Tratamiento de los valores NA
dataset$Age = ifelse(is.na(dataset$Age),
ave(dataset$Age, FUN = function(x) mean(x, na.rm = TRUE)),
dataset$Age)
dataset$Salary = ifelse(is.na(dataset$Salary),
ave(dataset$Salary, FUN = function(x) mean(x, na.rm = TRUE)),
dataset$Salary)
View(dataset)
str(dataset)
# Plantilla para el Pre Procesado de Datos - Datos Categóricos
# Importar el dataset
dataset = read.csv('Data.csv', stringsAsFactors = F)
str(dataset)
# Codificar las variables categóricas
dataset$Country = factor(dataset$Country,
levels = c("France", "Spain", "Germany"),
labels = c(1, 2, 3))
str(dataset)
dataset$Purchased = factor(dataset$Purchased,
levels = c("No", "Yes"),
labels = c(0,1))
str(dataset)
library(caTools)
set.seed(123)
split = sample.split(dataset$Purchased, SplitRatio = 0.8)
training_set = subset(dataset, split == TRUE)
testing_set = subset(dataset, split == FALSE)
View(testing_set)
View(training_set)
# Escalado de valores
training_set[,2:3] = scale(training_set[,2:3])
testing_set[,2:3] = scale(testing_set[,2:3])
install.packages("arules")
library(arules)
setwd("~/Documents/Cursos Udemy/Matematicas/machinelearning-az/datasets/Part 5 - Association Rule Learning/Section 28 - Apriori")
dataset = read.csv("Market_Basket_Optimisation.csv", header = FALSE)
View(dataset)
dataset = read.transactions("Market_Basket_Optimisation.csv",
sep = ",", rm.duplicates = TRUE)
View(dataset)
summary(dataset)
itemFrequencyPlot(dataset, topN = 10)
# Entrenar algoritmo Apriori con el dataset
rules = apriori(data = dataset,
parameter = list(support = 0.004, confidence = 0.2))
# Visualización de los resultados
inspect(sort(rules, by = 'lift')[1:10])
# Visualización de los resultados
inspect(sort(rules, by = 'lift')[1:10])
# Entrenar algoritmo Apriori con el dataset
rules = apriori(data = dataset,
parameter = list(support = 0.004, confidence = 0.1))
# Visualización de los resultados
inspect(sort(rules, by = 'lift')[1:10])
# Entrenar algoritmo Apriori con el dataset
rules = apriori(data = dataset,
parameter = list(support = 0.002, confidence = 0.1))
# Visualización de los resultados
inspect(sort(rules, by = 'lift')[1:10])