You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi i'm a South-Korean university student studying data science. I'm interested in Titanic data analysis. Your project is the best Titanic prediction algorithm I have ever seen. It was a great help to study. So I would like to send you the R code I analyzed(association rule, Regression analysis )
Hi i'm a South-Korean university student studying data science. I'm interested in Titanic data analysis. Your project is the best Titanic prediction algorithm I have ever seen. It was a great help to study. So I would like to send you the R code I analyzed(association rule, Regression analysis )
Titanic dataset.zip
`data<- read.csv("file location", header=T, na.strings=c("."))
data$survived <- factor(data$survived,levels=c(1,0),labels = c("y","n"))
data$pclass <- factor(data$pclass,levels=c(1,2,3),labels = c("1 grade","2 grade","3 grade"))
data$sibsp <- factor(data$sibsp,levels=c(0,1,2,3,4,5,8),labels = c("0","1","2","3","4","5","8"))
data$parch <- factor(data$parch,levels=c(0,1,2,3,4,5,6,9),labels = c("0","1","2","3","4","5","6","9"))
data <- data.frame(data$survived,data$pclass,data$sex,data$sibsp,data$parch,data$embarked,
data$age1,data$fare1)
#association rule
summary(data)
install.packages("arules")
library(arules)
rules.all <- apriori(data)
inspect(rules.all)
rules <- apriori(data,
control = list(verbose=F),
parameter = list(minlen = 2, supp = 0.005, conf=0.8),
appearance = list(rhs=c("data.survived=n",
"data.survived=y"),
default="lhs"))
quality(rules) <- round(quality(rules),digits=3)
rules.sorted <- sort(rules, by = "lift")
inspect(rules.sorted[1:2])
subset.matrix <- is.subset(rules.sorted, rules.sorted)
subset.matrix
redundant <- colSums(subset.matrix) > 0
redundant
rules.pruned <- rules.sorted[!redundant]
inspect(rules.pruned)
inspect(rules.pruned[1])
rules_1 <- apriori(data,
control = list(verbose=F),
parameter = list(minlen = 2, supp = 0.002, conf=0.2),
appearance = list(rhs=c("data.survived=n"),
lhs=c("data.pclass=1 grade",
"data.pclass=2 grade",
"data.pclass=3 grade",
"data.age1=kid","data.age1=adult"),
default="none"))
rules_1_sorted <- sort(rules_1,by="confidence")
inspect(rules_1_sorted)
//visual
install.packages("arulesViz")
library(arulesViz)
plot(rules.all)
plot(rules.all, method = "grouped")
#Regression analysis
data2 <- read.csv("C:/Users/dprnj/OneDrive/문서/KYK/Rworks/StatwithR/ch1/Data/titanic_full_2.csv", header=T, na.strings=c("."))
str(data2)
data2<-na.omit(data2)
plot(data2$sex,data2$survived)
cor(data2)
result1<-lm(data2$survived~data2$sex+data2$age+data2$fare,data=data2)
summary(result1)`
The text was updated successfully, but these errors were encountered: