forked from microsoft/LightGBM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prediction early stopping (microsoft#550)
* Add early stopping for prediction * Fix GBDT if-else prediction with early stopping * Small C++ embelishments to early stopping API and functions * Fix early stopping efficiency issue by creating a singleton for no early stopping * Python improvements to early stopping API * Add assertion check for binary and multiclass prediction score length * Update vcxproj and vcxproj.filters with new early stopping files * Remove inline from PredictRaw(), the linker was not able to find it otherwise
- Loading branch information
Showing
16 changed files
with
375 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef LIGHTGBM_PREDICTION_EARLY_STOP_H_ | ||
#define LIGHTGBM_PREDICTION_EARLY_STOP_H_ | ||
|
||
#include <functional> | ||
#include <string> | ||
|
||
#include <LightGBM/export.h> | ||
|
||
namespace LightGBM | ||
{ | ||
struct PredictionEarlyStopInstance | ||
{ | ||
/// Callback function type for early stopping. | ||
/// Takes current prediction and number of elements in prediction | ||
/// @returns true if prediction should stop according to criterion | ||
using FunctionType = std::function<bool(const double*, int)>; | ||
|
||
FunctionType callbackFunction; // callback function itself | ||
int roundPeriod; // call callbackFunction every `runPeriod` iterations | ||
}; | ||
|
||
struct PredictionEarlyStopConfig | ||
{ | ||
int roundPeriod; | ||
double marginThreshold; | ||
}; | ||
|
||
/// Create an early stopping algorithm of type `type`, with given roundPeriod and margin threshold | ||
LIGHTGBM_EXPORT PredictionEarlyStopInstance createPredictionEarlyStopInstance(const std::string& type, | ||
const PredictionEarlyStopConfig& config); | ||
|
||
} // namespace LightGBM | ||
|
||
#endif // LIGHTGBM_PREDICTION_EARLY_STOP_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.