Clang-tidy static analysis (#3222)

* Clang-tidy static analysis

* Modernise checks

* Google coding standard checks

* Identifier renaming according to Google style
This commit is contained in:
Rory Mitchell
2018-04-19 18:57:13 +12:00
committed by GitHub
parent 3242b0a378
commit ccf80703ef
97 changed files with 3407 additions and 3354 deletions

View File

@@ -36,21 +36,21 @@ class MyLogistic : public ObjFunction {
void GetGradient(HostDeviceVector<bst_float> *preds,
const MetaInfo &info,
int iter,
HostDeviceVector<bst_gpair> *out_gpair) override {
out_gpair->resize(preds->size());
std::vector<bst_float>& preds_h = preds->data_h();
std::vector<bst_gpair>& out_gpair_h = out_gpair->data_h();
HostDeviceVector<GradientPair> *out_gpair) override {
out_gpair->Resize(preds->Size());
std::vector<bst_float>& preds_h = preds->HostVector();
std::vector<GradientPair>& out_gpair_h = out_gpair->HostVector();
for (size_t i = 0; i < preds_h.size(); ++i) {
bst_float w = info.GetWeight(i);
// scale the negative examples!
if (info.labels[i] == 0.0f) w *= param_.scale_neg_weight;
if (info.labels_[i] == 0.0f) w *= param_.scale_neg_weight;
// logistic transformation
bst_float p = 1.0f / (1.0f + std::exp(-preds_h[i]));
// this is the gradient
bst_float grad = (p - info.labels[i]) * w;
bst_float grad = (p - info.labels_[i]) * w;
// this is the second order gradient
bst_float hess = p * (1.0f - p) * w;
out_gpair_h.at(i) = bst_gpair(grad, hess);
out_gpair_h.at(i) = GradientPair(grad, hess);
}
}
const char* DefaultEvalMetric() const override {
@@ -58,7 +58,7 @@ class MyLogistic : public ObjFunction {
}
void PredTransform(HostDeviceVector<bst_float> *io_preds) override {
// transform margin value to probability.
std::vector<bst_float> &preds = io_preds->data_h();
std::vector<bst_float> &preds = io_preds->HostVector();
for (size_t i = 0; i < preds.size(); ++i) {
preds[i] = 1.0f / (1.0f + std::exp(-preds[i]));
}