objective_function.cpp 1.34 KB
Newer Older
Guolin Ke's avatar
Guolin Ke committed
1
2
3
4
#include <LightGBM/objective_function.h>
#include "regression_objective.hpp"
#include "binary_objective.hpp"
#include "rank_objective.hpp"
5
#include "multiclass_objective.hpp"
Guolin Ke's avatar
Guolin Ke committed
6
7
8
9

namespace LightGBM {

ObjectiveFunction* ObjectiveFunction::CreateObjectiveFunction(const std::string& type, const ObjectiveConfig& config) {
10
11
  if (type == std::string("regression") || type == std::string("regression_l2")
      || type == std::string("mean_squared_error") || type == std::string("mse")) {
Guolin Ke's avatar
Guolin Ke committed
12
    return new RegressionL2loss(config);
13
14
  } else if (type == std::string("regression_l1") || type == std::string("mean_absolute_error")  || type == std::string("mae")) {
    return new RegressionL1loss(config);
Tsukasa OMOTO's avatar
Tsukasa OMOTO committed
15
  } else if (type == std::string("huber")) {
Tsukasa OMOTO's avatar
Tsukasa OMOTO committed
16
    return new RegressionHuberLoss(config);
Tsukasa OMOTO's avatar
Tsukasa OMOTO committed
17
18
  } else if (type == std::string("fair")) {
    return new RegressionFairLoss(config);
19
20
  } else if (type == std::string("poisson")) {
    return new RegressionPoissonLoss(config);
Guolin Ke's avatar
Guolin Ke committed
21
  } else if (type == std::string("binary")) {
Guolin Ke's avatar
Guolin Ke committed
22
    return new BinaryLogloss(config);
Guolin Ke's avatar
Guolin Ke committed
23
  } else if (type == std::string("lambdarank")) {
Guolin Ke's avatar
Guolin Ke committed
24
    return new LambdarankNDCG(config);
Guolin Ke's avatar
Guolin Ke committed
25
  } else if (type == std::string("multiclass")) {
Guolin Ke's avatar
Guolin Ke committed
26
27
28
    return new MulticlassSoftmax(config);
  } else if (type == std::string("multiclassova")) {
    return new MulticlassOVA(config);
Guolin Ke's avatar
Guolin Ke committed
29
30
31
32
  }
  return nullptr;
}
}  // namespace LightGBM