#----- Decision Tree --------
library(party)
t1 <- ctree(isIF ~.,
controls = ctree_control(maxdepth = 5, minbucket=10),
data=dfbasetrain)
plot(t1)
#---- k-means example ------------
#--- RFM 군집화 예제 ---
fit <- kmeans(df_RFM[8:10], 5)
table(fit$cluster)
plot(jitter(df_RFM$gF), jitter(df_RFM$gM), col=fit$cluster)
par(mfrow=c(1,2))
plot(jitter(df_RFM$gR), jitter(df_RFM$gF), col=fit$cluster)
barplot(1:5, col=1:5) # color label
par(mfrow=c(1,1))
clustRFM <- aggregate(df_RFM$gR~fit$cluster, FUN=mean)
clustRFM$meangF <- aggregate(df_RFM$gF~fit$cluster, FUN=mean)[,2]
clustRFM$meangM <- aggregate(df_RFM$gM~fit$cluster, FUN=mean)[,2]
barplot(t(as.matrix(clustRFM[,2:4])),
beside=TRUE,
names.arg = clustRFM[,1],
legend = rownames(t(as.matrix(clustRFM[,2:4]))))
plot(clustRFM$"df_RFM$gR", clustRFM$meangF, cex=table(fit$cluster)/20,
xlim=c(1,5), ylim=c(1,5), pch=19, col="lightblue")
text(clustRFM$"df_RFM$gR", clustRFM$meangF, 1:5)
plot(clustRFM$meangM, clustRFM$meangF, cex=table(fit$cluster)/20,
xlim=c(1,5), ylim=c(1,5), pch=19, col="lightblue")
text(clustRFM$meangM, clustRFM$meangF, 1:5)
cor(clustRFM[2:4])
'R 데이터 분석' 카테고리의 다른 글
[IsolationForest] Anomaly Detection (0) | 2018.08.30 |
---|---|
[DSM1809] statistical data analysis using R (0) | 2018.08.24 |
[KDBRBD] retail data analysis practice (0) | 2018.08.04 |
[CRMAJU2018] 기말고사 후보답안 예시 (0) | 2018.06.20 |
[ CRMAJU2018 ] 기말고사 (0) | 2018.06.20 |