commit the fix
This commit is contained in:
parent
93778aa4aa
commit
ecf6e8f49f
@ -200,11 +200,6 @@ namespace xgboost{
|
|||||||
fprintf(fo, "[%d]", iter);
|
fprintf(fo, "[%d]", iter);
|
||||||
for (size_t i = 0; i < evals.size(); ++i){
|
for (size_t i = 0; i < evals.size(); ++i){
|
||||||
this->PredictRaw(preds_, *evals[i]);
|
this->PredictRaw(preds_, *evals[i]);
|
||||||
for( size_t j = 0 ; j < preds_.size(); ++ j){
|
|
||||||
if( fabsf(preds_[j]- 0.5f)>1e-6f){
|
|
||||||
printf("p[%lu]=%f\n", j,preds_[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
obj_->PredTransform(preds_);
|
obj_->PredTransform(preds_);
|
||||||
evaluator_.Eval(fo, evname[i].c_str(), preds_, evals[i]->info);
|
evaluator_.Eval(fo, evname[i].c_str(), preds_, evals[i]->info);
|
||||||
}
|
}
|
||||||
@ -288,10 +283,7 @@ namespace xgboost{
|
|||||||
#pragma omp parallel for schedule( static )
|
#pragma omp parallel for schedule( static )
|
||||||
for (unsigned j = 0; j < ndata; ++j){
|
for (unsigned j = 0; j < ndata; ++j){
|
||||||
preds[j] = mparam.base_score + base_gbm.Predict(data.data, j, buffer_offset + j, data.info.GetRoot(j), bst_group );
|
preds[j] = mparam.base_score + base_gbm.Predict(data.data, j, buffer_offset + j, data.info.GetRoot(j), bst_group );
|
||||||
if( preds[j] != 0.5f ){
|
|
||||||
printf("pred[%d:%u]=%f\n", bst_group, j, preds[j]);
|
|
||||||
}
|
|
||||||
utils::Assert( preds[j] == 0.5f, "BUG");
|
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
#pragma omp parallel for schedule( static )
|
#pragma omp parallel for schedule( static )
|
||||||
|
|||||||
@ -102,14 +102,22 @@ namespace xgboost{
|
|||||||
|
|
||||||
/*! \brief Error */
|
/*! \brief Error */
|
||||||
struct EvalMatchError : public IEvaluator{
|
struct EvalMatchError : public IEvaluator{
|
||||||
|
public:
|
||||||
|
EvalMatchError(const char *name){
|
||||||
|
name_ = name;
|
||||||
|
abs_ = 0;
|
||||||
|
if(!strcmp("mabserror", name)) abs_ =1;
|
||||||
|
}
|
||||||
virtual float Eval(const std::vector<float> &preds,
|
virtual float Eval(const std::vector<float> &preds,
|
||||||
const DMatrix::Info &info) const {
|
const DMatrix::Info &info) const {
|
||||||
const unsigned ndata = static_cast<unsigned>(preds.size());
|
const unsigned ndata = static_cast<unsigned>(preds.size());
|
||||||
float sum = 0.0f, wsum = 0.0f;
|
float sum = 0.0f, wsum = 0.0f;
|
||||||
#pragma omp parallel for reduction(+:sum,wsum) schedule( static )
|
#pragma omp parallel for reduction(+:sum,wsum) schedule( static )
|
||||||
for (unsigned i = 0; i < ndata; ++i){
|
for (unsigned i = 0; i < ndata; ++i){
|
||||||
const float wt = info.GetWeight(i);
|
const float wt = info.GetWeight(i);
|
||||||
if (static_cast<int>(preds[i]) != static_cast<int>(info.labels[i]) ){
|
int label = static_cast<int>(info.labels[i]);
|
||||||
|
if( label < 0 && abs_ != 0 ) label = -label-1;
|
||||||
|
if (static_cast<int>(preds[i]) != label ){
|
||||||
sum += wt;
|
sum += wt;
|
||||||
}
|
}
|
||||||
wsum += wt;
|
wsum += wt;
|
||||||
@ -117,10 +125,13 @@ namespace xgboost{
|
|||||||
return sum / wsum;
|
return sum / wsum;
|
||||||
}
|
}
|
||||||
virtual const char *Name(void) const{
|
virtual const char *Name(void) const{
|
||||||
return "merror";
|
return name_.c_str();
|
||||||
}
|
}
|
||||||
|
int abs_;
|
||||||
|
std::string name_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Area under curve, for both classification and rank */
|
/*! \brief Area under curve, for both classification and rank */
|
||||||
struct EvalAuc : public IEvaluator{
|
struct EvalAuc : public IEvaluator{
|
||||||
virtual float Eval(const std::vector<float> &preds,
|
virtual float Eval(const std::vector<float> &preds,
|
||||||
@ -303,7 +314,8 @@ namespace xgboost{
|
|||||||
}
|
}
|
||||||
if (!strcmp(name, "rmse")) evals_.push_back(new EvalRMSE());
|
if (!strcmp(name, "rmse")) evals_.push_back(new EvalRMSE());
|
||||||
if (!strcmp(name, "error")) evals_.push_back(new EvalError());
|
if (!strcmp(name, "error")) evals_.push_back(new EvalError());
|
||||||
if (!strcmp(name, "merror")) evals_.push_back(new EvalMatchError());
|
if (!strcmp(name, "merror")) evals_.push_back(new EvalMatchError("merror"));
|
||||||
|
if (!strcmp(name, "mabserror")) evals_.push_back(new EvalMatchError("mabserror"));
|
||||||
if (!strcmp(name, "logloss")) evals_.push_back(new EvalLogLoss());
|
if (!strcmp(name, "logloss")) evals_.push_back(new EvalLogLoss());
|
||||||
if (!strcmp(name, "auc")) evals_.push_back(new EvalAuc());
|
if (!strcmp(name, "auc")) evals_.push_back(new EvalAuc());
|
||||||
if (!strncmp(name, "pre@", 4)) evals_.push_back(new EvalPrecision(name));
|
if (!strncmp(name, "pre@", 4)) evals_.push_back(new EvalPrecision(name));
|
||||||
|
|||||||
@ -134,6 +134,9 @@ namespace xgboost{
|
|||||||
}
|
}
|
||||||
Softmax( rec );
|
Softmax( rec );
|
||||||
int label = static_cast<int>(info.labels[j]);
|
int label = static_cast<int>(info.labels[j]);
|
||||||
|
if( label < 0 ){
|
||||||
|
label = -label - 1;
|
||||||
|
}
|
||||||
utils::Assert( label < nclass, "SoftmaxMultiClassObj: label exceed num_class" );
|
utils::Assert( label < nclass, "SoftmaxMultiClassObj: label exceed num_class" );
|
||||||
for( int k = 0; k < nclass; ++ k ){
|
for( int k = 0; k < nclass; ++ k ){
|
||||||
float p = rec[ k ];
|
float p = rec[ k ];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user