【问题标题】:Poor h2o GBM Classification Performance in a balanced binomial response平衡二项式响应中较差的 h2o GBM 分类性能
【发布时间】:2017-08-28 05:41:16
【问题描述】:

在一个相当平衡的二项式分类响应问题中,我在训练集本身上观察到 h2o.gbm 分类中用于确定类 0 的异常水平的错误。这是一场已经结束的比赛,所以兴趣只在于了解出了什么问题。

Confusion Matrix (vertical: actual; across: predicted) for F1-optimal threshold:
            0      1    Error            Rate
0      147857 234035 0.612830  =234035/381892
1       44782 271661 0.141517   =44782/316443
Totals 192639 505696 0.399260  =278817/698335

欢迎任何关于处理数据和减少错误的专家建议。 尝试了以下方法,发现错误没有减少。 方法 1:通过 h2o.varimp(gbm) 选择前 5 个重要变量 方法2:将负归一化变量转换为零,正变量为1。

    #Data Definition

# Variable                        Definition

#Independent Variables

# ID                                Unique ID for each observation
# Timestamp                       Unique value representing one day
# Stock_ID                        Unique ID representing one stock
# Volume                            Normalized values of volume traded of                  given stock ID on that timestamp
# Three_Day_Moving_Average        Normalized values of three days moving average of Closing price for given stock ID (Including Current day)
# Five_Day_Moving_Average           Normalized values of five days moving average of Closing price for given stock ID (Including Current day)
# Ten_Day_Moving_Average            Normalized values of ten days moving average of Closing price for given stock ID (Including Current day)
# Twenty_Day_Moving_Average       Normalized values of twenty days moving average of Closing price for given stock ID (Including Current day)
# True_Range                        Normalized values of true range for given stock ID
# Average_True_Range                Normalized values of average true range for given stock ID
# Positive_Directional_Movement   Normalized values of positive directional movement for given stock ID
# Negative_Directional_Movement   Normalized values of negative directional movement for given stock ID

#Dependent Response Variable
# Outcome                           Binary outcome variable representing whether price for one particular stock at the tomorrow’s market close is higher(1) or lower(0) compared to the price at today’s market close


temp <- tempfile()
download.file('https://github.com/meethariprasad/trikaal/raw/master/Competetions/AnalyticsVidhya/Stock_Closure/test_6lvBXoI.zip',temp)
test <- read.csv(unz(temp, "test.csv"))
unlink(temp)


temp <- tempfile()
download.file('https://github.com/meethariprasad/trikaal/raw/master/Competetions/AnalyticsVidhya/Stock_Closure/train_xup5Mf8.zip',temp)
#Please wait for 60 Mb file to load.
train <- read.csv(unz(temp, "train.csv"))
unlink(temp)

summary(train)

#We don't want the ID
train<-train[,2:ncol(train)]
# Preserving Test ID if needed
ID<-test$ID
#Remove ID from test
test<-test[,2:ncol(test)]
#Create Empty Response SalePrice
test$Outcome<-NA
#Original
combi.imp<-rbind(train,test)

rm(train,test)
summary(combi.imp)

#Creating Factor Variable
combi.imp$Outcome<-as.factor(combi.imp$Outcome)
combi.imp$Stock_ID<-as.factor(combi.imp$Stock_ID)
combi.imp$timestamp<-as.factor(combi.imp$timestamp)

summary(combi.imp)


#Brute Force NA treatment by taking only complete cases without NA.
train.complete<-combi.imp[1:702739,]
train.complete<-train.complete[complete.cases(train.complete),]
test.complete<-combi.imp[702740:804685,]

library(h2o)
y<-c("Outcome")
features=names(train.complete)[!names(train.complete) %in% c("Outcome")]
h2o.shutdown(prompt=F)
#Adjust memory size based on your system.
h2o.init(nthreads = -1,max_mem_size = "5g")

train.hex<-as.h2o(train.complete)
test.hex<-as.h2o(test.complete[,features])

#Models
gbmF_model_1 = h2o.gbm( x=features,
                        y = y,
                        training_frame =train.hex,
                        seed=1234
)
h2o.performance(gbmF_model_1)

【问题讨论】:

  • 这里没有足够的信息让我回复任何有用的信息,因为您是在寻求一般的数据科学建议(不提供有关数据集的信息),而不是寻求编码或软件方面的帮助。你需要一个可重现的例子,你需要解释为什么你认为 GBM 表现不佳。您期望性能如何?为什么?
  • 谢谢艾琳。 1. 可重现的示例:我放置的代码可以从任何带有 h2o 包的 R 工作室重现,因为数据是通过 URL 读取的。我们可以按原样运行此代码并获得结果。 2. 我们在训练数据中看到的对二元分类 0 分类的巨大错误分类,几乎 60%+。我假设这通常发生在不平衡的响应数据中,其中很少有响应属于 0 类,其余为 1 类。但这里的响应几乎 50% 是平衡的。问题是如何减少 0 的错误分类?
  • Erin,在代码的开头,我已经解释了每一列数据。这是我在数据集上拥有的唯一信息。
  • Hari,当我第一次发表评论时,我只看到了您的数据定义,而忽略了您实际上是在导入数据的事实。我仍然认为这更像是一个通用的数据科学/建模问题,而不是一个软件问题(代码本身没有错误或错误),所以我帮不上什么忙,抱歉。

标签: h2o gbm balanced-groups


【解决方案1】:

您只使用默认参数训练了一个 GBM,因此您似乎没有在调整模型方面付出足够的努力。我建议使用 h2o.grid() 函数在 GBM 上进行随机网格搜索。这是您可以关注的H2O R code example

【讨论】:

  • 谢谢艾琳。我肯定会这样做,我同意我的问题听起来很笼统。此外,我坚信对于证券交易所问题,我们总是需要通过导出典型交易者指标(如平均训练指数等)来进行特征工程。感谢您花一些时间在上面。我将这个问题保持开放,看看我们是否可以在几天内获得任何其他见解,然后将关闭。希望它本着stackoverflow的精神。再次感谢。
  • 事实证明,关注您的评论是一个很棒的决定。笛卡尔搜索而不是随机搜索并得到了很好的结果。谢谢艾琳!
猜你喜欢
  • 1970-01-01
  • 2021-06-22
  • 2018-05-08
  • 2022-08-23
  • 2018-03-07
  • 1970-01-01
  • 1970-01-01
  • 2019-09-20
  • 2019-08-27
相关资源
最近更新 更多