metric.cpp 881 Bytes
Newer Older
Guolin Ke's avatar
Guolin Ke committed
1
2
3
4
#include <LightGBM/metric.h>
#include "regression_metric.hpp"
#include "binary_metric.hpp"
#include "rank_metric.hpp"
5
#include "multiclass_metric.hpp"
Guolin Ke's avatar
Guolin Ke committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

namespace LightGBM {

Metric* Metric::CreateMetric(const std::string& type, const MetricConfig& config) {
  if (type == "l2") {
    return new L2Metric(config);
  } else if (type == "l1") {
    return new L1Metric(config);
  } else if (type == "binary_logloss") {
    return new BinaryLoglossMetric(config);
  } else if (type == "binary_error") {
    return new BinaryErrorMetric(config);
  } else if (type == "auc") {
    return new AUCMetric(config);
  } else if (type == "ndcg") {
    return new NDCGMetric(config);
22
23
24
25
  } else if (type == "multi_logloss"){
    return new MultiLoglossMetric(config);
  } else if (type == "multi_error"){
    return new MultiErrorMetric(config);
Guolin Ke's avatar
Guolin Ke committed
26
27
28
29
30
  }
  return nullptr;
}

}  // namespace LightGBM