new AUC code

This commit is contained in:
tqchen 2014-04-29 17:26:58 -07:00
parent 87a9c22795
commit 81414c0e5b
3 changed files with 8 additions and 4 deletions

View File

@ -256,6 +256,7 @@ namespace xgboost{
ModelParam(void){
base_score = 0.5f;
loss_type = 0;
num_feature = 0;
memset(reserved, 0, sizeof(reserved));
}
/*!

View File

@ -27,6 +27,8 @@ namespace xgboost{
const DMatrix::Info &info ) const = 0;
/*! \return name of metric */
virtual const char *Name(void) const = 0;
/*! \brief virtual destructor */
virtual ~IEvaluator(void){}
};
/*! \brief RMSE */
@ -104,8 +106,8 @@ namespace xgboost{
std::vector<unsigned> tgptr(2,0); tgptr[1] = preds.size();
const std::vector<unsigned> &gptr = info.group_ptr.size() == 0 ? tgptr : info.group_ptr;
utils::Assert( gptr.back() == preds.size(), "EvalAuc: group structure must match number of prediction" );
const unsigned ngroup = static_cast<unsigned>( gptr.size() );
const unsigned ngroup = static_cast<unsigned>( gptr.size() - 1 );
double sum_auc = 0.0f;
#pragma omp parallel reduction(+:sum_auc)
{

View File

@ -25,8 +25,9 @@ namespace xgboost{
const unsigned ndata = static_cast<unsigned>(preds.size());
#pragma omp parallel for schedule( static )
for (unsigned j = 0; j < ndata; ++j){
grad[j] = loss.FirstOrderGradient(preds[j], info.labels[j]) * info.GetWeight(j);
hess[j] = loss.SecondOrderGradient(preds[j], info.labels[j]) * info.GetWeight(j);
float p = loss.PredTransform(preds[j]);
grad[j] = loss.FirstOrderGradient(p, info.labels[j]) * info.GetWeight(j);
hess[j] = loss.SecondOrderGradient(p, info.labels[j]) * info.GetWeight(j);
}
}
virtual const char* DefaultEvalMetric(void) {