【问题标题】:How to fix PSOCKcluster error when running GBM运行 GBM 时如何修复 PSOCKcluster 错误
【发布时间】:2021-01-20 19:18:12
【问题描述】:

我正在尝试运行 gbm

gbm(formula=loan_status~., data=mdTrnGBM, distribution = 'bernoulli', n.trees= 100, interaction.depth= 5, bag.fraction= 0.5, cv.folds= 5)

并不断收到此错误:

makePSOCKcluster(names = spec, ...) 中的错误:
  集群设置失败。 8 名工作人员中有 8 名无法连接。 

关于如何解决这个问题的任何想法?如果我消除袋子分数和 cv 折叠,它确实会起作用,但我不想消除这些。

【问题讨论】:

    标签: r gbm


    【解决方案1】:

    当您指定 cv=5 时,gbm 使用 parallel 包将每个交叉验证作业发送到单独的核心。这可能是新 R 4.0 和 mac.. 或您可能正在使用的任何系统的新问题,请参阅 this link

    如果您的数据不是很大,现在您可以尝试仅使用 1 个核心,使用示例数据集:

    library(gbm)
    fl = "https://raw.githubusercontent.com/hrishibawane/DataLit/master/credit_train.csv"
    dat = read.csv(fl)
    dat = dat[dat$Loan.Status !="",]
    dat = droplevels(dat[complete.cases(dat),-c(1:2)])
    dat$Loan.Status = as.numeric(dat$Loan.Status)-1
    
    mdl = gbm(formula=Loan.Status~., data=dat, distribution = 'bernoulli', 
    n.trees= 100, interaction.depth= 5, bag.fraction= 0.5, cv.folds= 5,n.cores=1)
    
    gbm(formula = Loan.Status ~ ., distribution = "bernoulli", data = dat, 
        n.trees = 100, interaction.depth = 5, bag.fraction = 0.5, 
        cv.folds = 5, n.cores = 1)
    A gradient boosted model with bernoulli loss function.
    100 iterations were performed.
    The best cross-validation iteration was 98.
    There were 16 predictors of which 16 had non-zero influence.
    

    【讨论】:

      猜你喜欢
      • 2015-10-31
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-20
      相关资源
      最近更新 更多