-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sampling&Aprori.r
52 lines (35 loc) · 1.5 KB
/
Sampling&Aprori.r
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
## Step.1
## In this step, we completed the following works:
## > sampling from source data,
## > pretreatment for the aprori,
## > get association rules,
## > re-process the results.
library("arules")
## This part is the sampling from source data.
print('Waiting ...')
AllG <- read.csv(
"IN/weishengsu_expression_change.csv",header = F,stringsAsFactors = FALSE)
AllG <- data.frame(t(AllG))
AllG <- AllG[,-1]
G100 <- sample(AllG,100)
G100 <- data.frame(t(G100))
write.csv(G100,TEST_DATA,row.names = F)
## This part is the pretreatment of association rules.
jRow <- length(rownames(AllG))
jDim <- 2
jFin <- paste(getwd(),TEST_DATA,sep = '/')
jFout <- paste(getwd(),"EX/rules/Mult_data_100.txt",sep = '/')
system("javac preTreatment.java")
system(paste("java preTreatment",jRow,jDim,jFin,jFout,sep = ' '))
## This part use the encapsulated function 'apriori' to complete the analysis of association rules.
tr <- read.transactions("EX/rules/Mult_data_100.txt", format="basket", sep = ",")
rules = apriori(tr,parameter = list(support = 0.15,confidence = 0.45,minlen = 2,maxlen = 2)) #pre 0.3 0.6
summary(rules)
outdata <- as(rules,"data.frame")
write.table(outdata,"EX/rules/Result.csv",sep = ",")
# This part is the further processing of the results after association rules.
jRules <- length(rules)
jFin <- paste(getwd(),"EX/rules/Result.csv",sep = '/')
jFout <- paste(getwd(),"EX/rules/sum_data.csv",sep = '/')
system("javac furTreatment.java")
system(paste("java furTreatment",jRules,jFin,jFout,sep = ' '))