I have strings with numbers as rules
make_rule <- function(n=5){
x1 <- sample(1:20,n)
x2 <- sample(c(" <= "," >= "),n,replace = T)
x3 <- round(rnorm(n),4)
res <- paste0("X[,",x1,"]", x2 , x3,collapse = " & ")
return( res )
}
rules <- lapply(1:10000, function(x) make_rule(n=sample(2:5,1)) )
..
head(rules)
[[1]]
[1] "X[,16] <= -0.664 & X[,11] <= -2.1891 & X[,17] >= -0.4138"
[[2]]
[1] "X[,1] <= 1.2584 & X[,11] >= -0.7082 & X[,20] <= -0.0806"
[[3]]
[1] "X[,3] <= -0.6363 & X[,7] >= -0.853 & X[,10] >= -3.4069"
[[4]]
[1] "X[,7] <= 0.5907 & X[,1] <= 0.5892 & X[,8] >= -2.1081 & X[,9] >= -1.4655 & X[,18] >= 0.0914"
Strings have different lengths and numeric values inside
That is, I probably need to apply two distances
- for numbers
"X[,16] <= -0.664 & X[,11] <= -2.1891 & X[,17] >= -0.4138"
- for character
"X[,16] <= -0.664 & X[,11] <= -2.1891 & X[,17] >= -0.4138"
How it is possible to make clustering of such data?