I am working on a classification problem, and am applying gradient boosted tress on the dataset, to classify the items into two classes (Fraud -> 1 and No Fraud -> 0)

I am using the below code for my glm methos :

formula = paste(class.label,paste(vars,collapse = ' + '), sep = ' ~ ')

modelGBM = gbm(as.formula(formula), data =  creditdataset,
           distribution = 'bernoulli',
           n.trees = 400,
           interaction.depth = 3,
           shrinkage = 0.05,
           bag.fraction = 0.5,
           keep.data = FALSE,
           cv.folds = 5

where creditdataset is my dataset.

After I execute the code , I get the following error message :

Error in serialize(data, node$con) : error writing to connection

I know this kind of error has been discussed here : [https://stackoverflow.com/questions/28503208/doparallel-error-in-r-error-in-serializedata-nodecon-error-writing-to-con][1]

and here :


but these two posts don't really solve the problem. Can anyone point me in the right direction here.

  • $\begingroup$ I note that you've writtten 'glm' (generalised linear model) in your header rather than the correct 'gbm', which may lead to not getting people with the right skills reading your question. $\endgroup$ Mar 27, 2017 at 5:33
  • $\begingroup$ Oh , thanks for pointing that out! Made the changes, I hope I get some response on this $\endgroup$
    – user47
    Mar 28, 2017 at 3:12

1 Answer 1


I had a similar issue. I tried using train from the caret package to solve the issue.

The code will look like:

ctrl <- trainControl(method = "cv", 
                     summaryFunction = twoClassSummary, 
                     classProbs = TRUE)

fit = train(formula,data= creditdataset, method = "gbm",trControl = ctrl,metric = "ROC")

Make sure you see other options in trControl.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.