Dart - very poor accuracy
When I use dart as a booster I always get very poor performance in term of l2 result for regression task. Even If I use small drop_rate = 0.01 or big like 0.3.
When I use dart in xgboost on same dataset, with similar setting (same learning rate, similiar num_trees) dart alwasy give me boost for accuracy (small but always).
But here accuracy is poor badly, like there is a bug, not just dart is not suitable for my task.
Can anyone confirm that dart is working for regression task in term of better accuracy?
My setting is as follows (part of the Python code for ramdom search of params):
lr = np.random.choice([0.01, 0.005, 0.0025]) list_count = np.random.choice([250, 500, 750, 1000]) min_in_leaf = np.random.choice([25, 50, 100]) subF = np.random.choice([0.15, 0.22, 0.3, 0.5, 0.66, 0.75]) subR = np.random.choice([0.66, 0.75, 0.83, 0.9]) max_depth = np.random.choice([9, 11, 15, 25, 45, 100, -1]) dart_rate = np.random.choice([0, 0, 0, 0.01, 0.03, 0.1]) max_bin = np.random.choice([63, 127, 255, 511]) lambda_l1 = np.random.choice([0, 1., 10., 100.]) lambda_l2 = np.random.choice([0, 1., 10., 100.])
iterace = 10000 if only_testing: min_in_leaf = 25 iterace = 10
boost_type = 'gbdt' if dart_rate > 0: boost_type = 'dart'
params = {
'task' : 'train',
'boosting_type' : boost_type,
'objective' : 'regression',
'metric' : 'l2',
'max_depth' : int(max_depth),
'num_leaves' : int(list_count),
'min_data_in_leaf' : int(min_in_leaf),
'learning_rate' : lr,
'feature_fraction' : subF,
'bagging_fraction' : subR,
'bagging_freq': 1,
'verbose' : 0,
'nthread' : nthread,
'drop_rate': dart_rate,
'max_bin': max_bin,
'lambda_l1' : lambda_l1,
'lambda_l2' : lambda_l2
}
model = lg.train( params, (matrix_learn, target_learn), num_boost_round = iterace, valid_datas = (matrix_test, target_test), early_stopping_rounds = 50 )
What is working in XGB is probably not just drop_rate but also skip_drop. http://xgboost.readthedocs.io/en/latest/tutorials/dart.html
Can you please support this as well?
@wxchan
https://github.com/dmlc/xgboost/blob/master/src/gbm/gbtree.cc#L547-L711
can you check the code of implementation in XGBoost, and figure out why?
@guolinke I read these codes before. It's not hard to be added, but I have no idea where he came upon those parameters.
@gugatr0n1c
- Can you provide how you set up skip_rate etc. for xgboost?
- Do you know where xgboost gets the ideas of skip_rate, sample_type and normalize_type?
- Can you show accuracy comparisons between xgboost and lightgbm (both gbdt & dart) for your task?
@wxchan, I am not familiar with XGBoost. Following is my guess:
weight_dropis the weights of all trees, not just dropped trees, right? If yes, I think the line you refer to is a bug. it should beweight_drop[idx_drop[i]] *= factor. If this is a bug, I am not sure why XGBoost can preform better....- It seems drop tree logic is based on sum_weight in XGBoost, but LightGBM is just random. Maybe we can adapt this.
@guolinke I can add that option. I will do some investigations on this.
@wxchan ad1] usually I run random search on parameters, and for xgboost on my datasets best setting is: skip_rate = 0.3 drop_rate = 0.2 I use default for next two dart parameters.
ad2] actually dart for xgboost was done with my issue here https://github.com/dmlc/xgboost/issues/809 And it seems to that marugari add skip_rate just like his idea. On other two setting I do not know the source.
ad3] my task is regression problem with 500k rows, 400 features, and RMSE on cross validation: randomforest from scikit: 5.46 deepnet (5 hidden layers, prelu, adam, xavier) from mxnet 5.43 xgboost without dart: 5.421 xgboost with dart: 5.419 lightgbm without dart: 5.418 lightgbm with dart: 5.5 - not a chance to beat randomforest
For all methods I did some random search of parameters and method should be comparable in the sence of RMSE. Speed is best for deepnet - but it is different algorithm (also depends on settings and hardware).
@gugatr0n1c Can you test two things on your dataset:
- For lightgbm dart, set drop_rate to a very small number, such as drop_rate=1/num_iter; because your num_iter is big, each trees may be dropped too many times;
- For xgboost dart, set learning rate=1. For dart, learning rate is a different concept from gbdt. In original paper, it's fixed to 1.
It's not so difficult to add skip_rate and normalize_type.
If there are users, I will PR.
@wxchan ad1] I tried with 0.005, 0.0005, 0.0001 and got similar "bad" results... strange is that early stopping stop training very early (hundreds of iterations with compare two several thousands without dart)
ad2] I can do this tomorrow from work
@marugari where do you get the idea about skip_rate and normalize_type?
another question: when sample_type = weighted in xgboost, dparam.rate_drop * weight_drop.size() * weight_drop[i] / sum_weight (from here) can be bigger than 1, the probability of 'this' tree being selected is calculated as some number bigger than 1 but actually 1. Will it cause the expectation of dropped trees number smaller than rate_drop?
@wxchan Regarding skip_rate, All we have to do is leaving idx_drop empty.
In order to use learning_rate < 1 in dart, I propose the following:
/* dart.hpp L:103 */
if (normalize_type == 1) {
shrinkage_rate_ = learning_rate_ / (1.0 + learning_rate_);
} else {
shrinkage_rate_ = learning_rate_ / (drop_index_.size() + learning_rate_);
}
/* dart.hpp L:119 */
if (normalize_type == 1) {
models_[curr_tree]->Shrinkage(-k / learning_rate_);
} else {
models_[curr_tree]->Shrinkage(-1 / learning_rate_);
}
sample_type is very rough, since I think it's not involved in convergence.
@marugari sorry, what I meant is, is there some paper regarding skip_rate and normalize_type, because they are not shown in dart original paper?
@wxchan sorry. They are my extensions, not published.
@marugari I see, thanks.
If you want to use skip_rate, you can arrange a callback with changing drop_rate.
Just my opinion on this: I think the parameters I add 'here' should be tested, I am not saying they are wrong, they can be wonderful ideas, but I want to be convinced before I add them 'here'.
skip_rate and sample_type added to my dart branch.
@wxchan If I set in xgboost learning_rate to 1, accuracy is very bad as well, even worse than here...
@gugatr0n1c in original paper, they only use shrinkage_rate=1/(1+num_drop_trees); as marugari said, he set shrinkage_rate_ = learning_rate_ / (drop_index_.size() + learning_rate_); I think this is the main difference rather than skip_rate or sample_type.
But according to code in xgboost:
float factor = 1.0 * num_drop / (num_drop + lr);
for (size_t i = 0; i < idx_drop.size(); ++i) {
weight_drop[i] *= factor;
}
for (size_t i = 0; i < size_new_trees; ++i) {
weight_drop.push_back(1.0 / (num_drop + lr));
}
If num_drop is a reasonable integer, num_drop+lr should not have big differences when lr=1 or lr=0.1. It has a lot of math involved in deciding these weights, I actually don't fully get it.
Another difference: in original paper, their strategy is at least dropping one tree each round, which means num_drop >= 1, this is what I implemented too. xgboost don't have this 'at least one' part(in the mean time, they have skip_drop, with making num_drop=0 directly). It means, with a lr = 0.1 for example, weights of new trees can be very large (1/(0+0.1)=10). I think it's not correct.
As I wrote I did not used 'sample_type' parameter. I only used 'drop_rate' and 'skip_rate' (together with learning_rate << 1) in xgboost. And it was working nicely. I can not say now the influence of 'skip_rate'. But when I used random search for hyperparameters tuning, it always wanted to set 'skip_rate' to something non zero. But, yes I agree that the main trick is to adapt shrinkage_rate as written.
But to be honest, if I can use below to simulate 'skip_rate', then it is not necessary to add this parameter, just maybe mention it as an example about callback? Actually it is even better solution, because I can then randomize drop_rate together with skip_rate (this is not even in xgboost) during learning process by some logic in generating drop_rate_list.
-->simulate 0.33 skip_rate drop_rate_list = np.random.choice([0., 0.3, 0.3], iteration_count).tolist() lg.train( params, data_train, num_boost_round = iteration_count, valid_sets = data_valid, early_stopping_rounds = 50, callbacks = [lg.reset_parameter(drop_rate = drop_rate_list)] )
So I believe there are nice things to do: 1] allow change drop_rate in callback, should work now right?, 2] change shrinkage_rate as marugari wrote.
@wxchan Although weight_drop of new trees can be large, leaf values of that are scaled by learning_rate.
I think weight_drop * learning_rate = 1.0.