I have a `bnlearn` model in R that is learned using the `gs` function with 4 categorical variables and 8 numerical variables.
when I try to validate my model with a test set, I get this error when trying to predict some of the nodes:

> 
> Error in check.fit.vs.data(fitted = object, data = data, subset = object[[node]]$parents) :  
> 
>  'Keyword' has different number of levels in the node and in the data.
> 
> 
> 

Is it not possible to use both numerical and categorical variables with `bnlearn`? and if it is possible, what am I doing wrong?

```
mydata$A <- as.factor(mydata$A)
mydata$B <- as.numeric(mydata$B)
mydata$C <- as.numeric(mydata$C)
mydata$D <- as.numeric(mydata$D)
mydata$E <- as.factor(mydata$E)
mydata$F <- as.numeric(mydata$F)
mydata$G <- as.numeric(mydata$G)
mydata$H <- as.numeric(mydata$H)
mydata$I <- as.numeric(mydata$I)
mydata$J <- as.numeric(mydata$J)
mydata$K <- as.numeric(mydata$K)
mydata$L <- as.numeric(mydata$L)
mydata$M <- as.numeric(mydata$M)
mydata$N <- as.numeric(mydata$N)
mydata$O <- as.numeric(mydata$O)
mydata$P <- as.numeric(mydata$P)
mydata$Q <- as.numeric(mydata$Q)

#create vector of black arcs
temp1=vector(mode = "character", length = 0)
for (i in 1:length(varnames)){
    for (j in 1:length(varnames)){
        temp1 <- c(temp1,varnames[i])
        }
    }

temp2=vector(mode = "character", length = 0)
for (i in 1:length(varnames)){
    temp2 <- c(temp2,varnames)
    }

#creat to arcs of the model
arcdata = read.csv("C:/users/asaf/desktop/in progress/whitearcs.csv", header = T)
wfrom=arcdata[,1]
wto=arcdata[,2]

whitelist = data.frame(from = wfrom,to =wto)

#block unwanted arcs

blacklist = data.frame(from = temp1, to = temp2)

#fit and plot the model

#gaussian method
model = gs(mydata, whitelist = whitelist, blacklist = blacklist)

#inference procedure

learntmodel = bn.fit(model,mydata,method = "mle",debug = F)

graphviz.plot(learntmodel)
myvalidation=read.csv("C:/users/asaf/desktop/in progress/val.csv",    header = T)
#predicate A
pred = predict(learntmodel, node="A", myvalidation)
myvalidation$A <- pred

#predicate B
pred = predict(learntmodel, node="B", myvalidation)
myvalidation$B <- pred

```

at this point it throws the following error :

> 
> Error in check.fit.vs.data(fitted = object, data = data, subset = object[[node]]$parents) :  
> 
>  'A' has different number of levels in the node and in the data.
> 
> 
>