chg all settings to obj

This commit is contained in:
tqchen
2014-05-16 19:10:52 -07:00
parent 213375baca
commit 98e507451c
10 changed files with 30 additions and 22 deletions

View File

@@ -25,7 +25,7 @@ namespace xgboost{
RegRankBoostLearner(void){
silent = 0;
obj_ = NULL;
name_obj_ = "reg";
name_obj_ = "reg:linear";
}
/*!
* \brief a regression booter associated with training and evaluating data

View File

@@ -129,7 +129,9 @@ namespace xgboost{
if( fs.Read(&nwt, sizeof(unsigned) ) != 0 ){
utils::Assert( nwt == 0 || nwt == data.NumRow(), "invalid weight" );
info.weights.resize( nwt );
utils::Assert( fs.Read(&info.weights[0], sizeof(unsigned) * nwt) != 0, "Load weight file");
if( nwt != 0 ){
utils::Assert( fs.Read(&info.weights[0], sizeof(unsigned) * nwt) != 0, "Load weight file");
}
}
}
fs.Close();

View File

@@ -109,15 +109,16 @@ namespace xgboost{
namespace xgboost{
namespace regrank{
inline IObjFunction* CreateObjFunction( const char *name ){
if( !strcmp("reg", name ) ) return new RegressionObj();
if( !strcmp("rank:pairwise", name ) ) return new PairwiseRankObj();
if( !strcmp("rank:softmax", name ) ) return new SoftmaxRankObj();
if( !strcmp("softmax", name ) ) return new SoftmaxMultiClassObj();
// if (!strcmp("lambdarank:map", name)) return new LambdaRankObj_MAP();
// if (!strcmp("lambdarank:ndcg", name)) return new LambdaRankObj_NDCG();
utils::Error("unknown objective function type");
return NULL;
}
if( !strcmp("reg:linear", name ) ) return new RegressionObj( LossType::kLinearSquare );
if( !strcmp("reg:logistic", name ) ) return new RegressionObj( LossType::kLogisticNeglik );
if( !strcmp("binary:logistic", name ) ) return new RegressionObj( LossType::kLogisticClassify );
if( !strcmp("binary:logitraw", name ) ) return new RegressionObj( LossType::kLogisticRaw );
if( !strcmp("multi:softmax", name ) ) return new SoftmaxMultiClassObj();
if( !strcmp("rank:pairwise", name ) ) return new PairwiseRankObj();
if( !strcmp("rank:softmax", name ) ) return new SoftmaxRankObj();
utils::Error("unknown objective function type");
return NULL;
}
};
};
#endif

View File

@@ -14,8 +14,8 @@ namespace xgboost{
namespace regrank{
class RegressionObj : public IObjFunction{
public:
RegressionObj(void){
loss.loss_type = LossType::kLinearSquare;
RegressionObj( int loss_type ){
loss.loss_type = loss_type;
}
virtual ~RegressionObj(){}
virtual void SetParam(const char *name, const char *val){