I am trying to fit a fpgrowth model on a in-built data set called Adult. While fitting a model, I was getting an error as shown below.
Error in .jcall(jPruning, "[[Ljava/lang/String;", "fpgrowth", support, :
method fpgrowth with signature (DDI)[[Ljava/lang/String; not found
I used the below R code to fit fpgrowth model.
library(rCBA)
data("Adult")
Adult<-as(Adult,"transactions")
rules = rCBA::fpgrowth(Adult, support=0.001, confidence=0.5, maxLength=2)
What's wrong with the above code?
Thanks in advance.
you must specify your "class" or consequent
rules = rCBA::fpgrowth(Adult, support=0.001, confidence=0.5, maxLength=2, consequent="Species")
Try with This:
https://rdrr.io/cran/rCBA/src/R/fpgrowth.R
Related
I am trying to use XGBoost to enhance the Accuracy of my model. While I am new to xgboost, I have been trying to understand this algorithm through various sources. I have set the param list with the following code:
param = list("objective"="binary:logistic", "eval_metric"="logloss", "eta"=1, "max.depth"=2)
and then used:
xg.cv = xgb.cv(params=param, data=as.matrix(train), label=train$StatusDesc,
nthread=2, nrounds=2, nfold=5)
When I run this, I get the below error:
Error in xgb.DMatrix(data, label = label, missing = missing) :
[19:55:03] amalgamation/../dmlc-core/src/io/local_filesys.cc:66:
LocalFileSystem.GetPathInfo 20160906 Error:No such file or directory.
Can someone help me with this error?
Try it. This solved some of my problems.
install.packages("drat", repos="https://cran.rstudio.com")
drat:::addRepo("dmlc")
install.packages("xgboost", repos="http://dmlc.ml/drat/",type="source")
I'm currently working on preditive models with the 'randomForest' package.
Fitting my model as follow
rf <- foreach(ntree=rep(10, 3), .combine= combine, .packages='randomForest') %dopar% {
randomForest(bou~.,data=train, trees=50, importance=TRUE)}
When using 'confusionMatrix' from the 'caret' package, I've got the results below :
I'd like to know if it's possible to set the positive class to 1 in the model. I searched in the package description but couldn't find anything about it.
Thank you very much.
Edit : I've found it. It's an option in the 'confusionMatrix' command from the 'caret' package. I was lokking at the wrong place. Here an example if needed.
confusionMatrix(predicted,true_values,positive='1')
Should I leave my post or delete it ?
I've found it. It's an option in the confusionMatrix command from the caret package. I was looking at the wrong place. Here an example if needed:
confusionMatrix(predicted,true_values,positive='1')
I'm working on a simple multigroup path model (test of moderated mediation) in lavaan and getting an odd error.
Here is my model:
model <-'
MC ~ c(c1,c2)*RA
RP ~ c(a1,a2)*RA
MC ~ c(b1,b2)*RP'
When I go to use check the model using the lavaanify command, like this:
lavaanify(model)
I get the following error:
lavaan ERROR: wrong number of arguments in modifier (c1,c2) of element MC~RA
I've also tried using the model with the sem command itself (while specifying a grouping variable) and get the same error.
Can anyone help me along the path here?
Thanks!
Ryan
I am trying to use predict function in R using a model saved earlier. The model was created and saved using the following code:
lrModel1 <- glm(response ~ .,data = modelData,family = binomial,model = TRUE)
save(lrModel1,file = "lrModel100.rda")
When I load the model for later use as follows and try to use the predict function on it as follows:
bar <- load("lrModel100.rda")
predicted <- predict(bar,validationData,type = "response")
I get the following error:
Error in UseMethod("predict") :
no applicable method for 'predict' applied to an object of class "character"
Is there a way to get the model object name from the saved RDA file and use it for prediction?
Thank you.
Ravi
As #droopy told you the model's name doesn't change if you save and load. You can use get to use the model:
predicted <- predict(get(bar),validationData,type = "response")
If you have saved the model earlier it may throw this error.
Reload the library(glmnet) and make sure that number of variables in X & Y are same.
I have same problem before.
I used caret to build model, and save the model as a rds file.(saveRDS)
When I readRDS my file, and use this model to predict, I encountered this problem.
After I use "library(caret)", my problem is solved.
So I think if you save your model, and re-open your model to predict, you have to reload the package you used for building model.
I am trying to use bestglm on a logistic regression model fitting a smaller sample of my data (100x25) matrix (originaly 250kx40).
I run it in BATCH mode. and I wish to write the bestglm models to a file.
dput(test2,file="test2.txt",control=c("keepNA","keepInteger","showAttributes"))
t2<-dget(file="test2.txt")
Error in UseMethod("family") :
no applicable method for 'family' applied to an object of class "NULL"
Any ideas as to how to solve this problem?
There is something in the dput'ing of the bestglm that isn't right. If you simply dput to the console, copy+paste it back in to a new object, it will fail with the same error.
It may be a bug and you may want to reach out to the package maintainer(s).
In the meantime, try using saveRDS and readRDS:
saveRDS(test2, file="test2.rds")
t2 <- readRDS("test2.rds")