add in grad and hess rescale in lambdarank

This commit is contained in:
kalenhaha 2014-05-14 23:13:27 +08:00
parent 671c34be63
commit 121348c0d7
7 changed files with 14 additions and 30 deletions

View File

@ -1,5 +0,0 @@
1 0:2 1:3 2:2
0 0:2 1:3 2:2
0 0:2 1:3 2:2
0 0:2 1:3 2:2
1 0:2 1:3 2:2

View File

@ -1,2 +0,0 @@
2
3

View File

@ -1,5 +0,0 @@
1 0:2 1:3 2:2
0 0:2 1:3 2:2
0 0:2 1:3 2:2
0 0:2 1:3 2:2
1 0:2 1:3 2:2

View File

@ -1,2 +0,0 @@
2
3

View File

@ -1,11 +0,0 @@
1 0:1.2 1:3 2:5.6
0 0:2.0 1:2.3 2:5.1
0 0:3.9 1:3 2:3.1
0 0:2 1:3.2 2:3.4
1 0:2.1 1:4.5 2:4.2
0 0:1.9 1:2.8 2:3.1
1 0:3.0 1:2.0 2:1.1
0 0:1.9 1:1.8 2:2.1
0 0:1.1 1:2.2 2:1.4
1 0:2.1 1:4.1 2:4.0
0 0:1.9 1:2.2 2:1.1

View File

@ -1,2 +0,0 @@
6
5

View File

@ -281,10 +281,12 @@ namespace xgboost{
virtual void SetParam(const char *name, const char *val){
if( !strcmp( "loss_type", name ) ) loss_.loss_type = atoi( val );
if( !strcmp( "fix_list_weight", name ) ) fix_list_weight_ = (float)atof( val );
}
private:
LossType loss_;
float fix_list_weight_;
protected:
class Triple{
@ -372,6 +374,15 @@ namespace xgboost{
grad[pairs[i].first] += first_order_gradient;
hess[pairs[i].second] += second_order_gradient;
grad[pairs[i].second] -= first_order_gradient;
}
if( fix_list_weight_ != 0.0f ){
float scale = fix_list_weight_ / (group_index[group+1] - group_index[group]);
for(unsigned j = group_index[group]; j < group_index[group+1]; ++j ){
grad[j] *= scale;
hess[j] *= scale;
}
}
}