Commit 5722e75b authored by Vincent Mazenod's avatar Vincent Mazenod
Browse files

add graduel with tids and dataset

parent 6ec2a1f7
......@@ -26,4 +26,7 @@ yarn-error.log
/.env
/admin/node_modules/
/mercure/updates.db
/public/uploads/
\ No newline at end of file
/public/uploads/
.vscode
FileForAprioriTID.txt
**/FileForAprioriTID.txt
\ No newline at end of file
## inputs parameters
argv <- commandArgs(TRUE)
# -- The minimum support --
#minSup <- as.double(argv[1])
minSup <- as.double(argv[2])
# -- The minimum length of extracted gradual pattern
#minLength <- as.integer(argv[2])
minLength <- as.integer(1)
# -- Input file
#input <- argv[3]
input <- argv[1]
# -- Output file
output <- argv[3]
# -- Define output tempon file & input Convolution
outputInputTemp <- "FileForAprioriTID.txt"
# -- The Firts constant
#k1 <- as.numeric(argv[5])
k1 <- 0
# -- The Second constant
#k2 <- as.numeric(argv[6])
k2 <- 0
cat("\n")
cat("----- The minimum support is ", minSup, "------ \n")
cat("\n")
cat("----- The minimum length of extracted gradual pattern is ", minLength, "----\n")
cat("\n")
cat("----- The Firts constant is", k1, "----\n")
cat("\n")
cat("----- The second constant is ", k2, "----\n")
cat("\n")
#cat("----- The separator of data is ", argv[7], "------ \n")
#cat("----- The separator of data is ", argv[3], "------ \n")
cat("----- The separator of data is ", " ", "------ \n")
cat("\n")
## import library Java
library("rJava")
## Read input data file
#data <- read.csv(input, sep = argv[7])
#data <- read.csv(input, sep = argv[3])
data <- read.csv(input, sep = " ")
## ------ The beginning of the standard deviation ------
## Transform dataframe to matrix
data_mat <- as.matrix(data)
## ------ Time ------
t1 <- Sys.time()
## ------ Debut standard deviation (sd) ------
ecarttype <- vector("numeric",ncol(data_mat))
for (i in 1 : ncol(data_mat)){
ecarttype[i] <- (sd(data_mat[,i]) * k1) + k2
}
## ------ Fin standard deviation ------
## ------ The beginning of the NumVersCat procedure -------
data_diff <- diff(data_mat)
## -- Util pour APRIORI
tab_vec <- array()
## Transform numerical data matrix to categorical data matrix containing "+", "-" and "o" items
data_cat <- matrix(0, nrow = nrow(data_diff), ncol = ncol(data_diff))
for(i in 1:ncol(data_diff)){
for(j in 1 : nrow(data_diff)){
if ((data_diff[j,i] > ecarttype[i]) & (data_diff[j,i] > 0)){
data_cat[j,i] <-paste0(paste0("X",i),"=+") # Xi=+
}else if((abs(data_diff[j,i]) > ecarttype[i]) & (data_diff[j,i] < 0)){
data_cat[j,i] <-paste0(paste0("X",i),"=-") #Xi=-
}else{
data_cat[j,i] <-paste0(paste0("X",i),"=o") #Xi=o
}
}
}
# ----------------------------------
for (i in 1:nrow(data_cat)) {
for(j in 1:ncol(data_cat)){
if (j == 1) {tab_vec[i] <- data_cat[i,j]}else{tab_vec[i] <- paste(tab_vec[i], data_cat[i,j])}
}
}
# ----------------------------------
# -- Ecrire dans un fichier tempon pour traitement par AprioriTID
write(tab_vec, file = outputInputTemp, sep =" ")
### ----- Dbut Insertion du code java -----
# -- initialisation of the JVM
.jinit()
# -- Add .jar file to the class path
.jaddClassPath("AprioriTID.jar")
# -- instatiation of the Class
obj <- .jnew("AlgoAprioriTID")
cat("----- BEFORE APRIORI ----\n")
# -- Call function directly with parameters
.jcall(obj, "V", "runAlgorithmModifier", outputInputTemp, output, minSup, minLength)
cat("----- AFTER APRIORI ----\n")
t2 <- Sys.time()
t2 - t1
cat("\n")
x1 x2 x3 x4 x5 x6 x7
84 61 7 0 1 8 0
116 36 4 1 11 2 31
90 52 2 3 5 1 13
124 34 1 5 12 7 36
102 49 0 6 7 10 17
135 17 0 1 18 3 62
106 40 3 1 9 0 18
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment