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.
introduce random assignment prediction(microsoft#5177)
* Introduce a struct of parameters PredictionControlParameter * Add a new field random_assign_features to class Config * Add new GetLeaf functions that apply random assign mechanism to class Tree
- Loading branch information
1 parent
858eeb5
commit 0fc8c2f
Showing
10 changed files
with
217 additions
and
40 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,40 @@ | ||
|
||
/*! | ||
* Copyright (c) 2017 Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See LICENSE file in the project root for license information. | ||
*/ | ||
#ifndef LIGHTGBM_PREDICTION_CONTROL_PARAMETER_H_ | ||
#define LIGHTGBM_PREDICTION_CONTROL_PARAMETER_H_ | ||
|
||
|
||
#include <vector> | ||
#include <algorithm> | ||
|
||
namespace LightGBM { | ||
|
||
/*! | ||
* \brief Control paramters for prediction, used to implement variants of prediction algorithm | ||
*/ | ||
struct PredictionControlParameter { | ||
public: | ||
PredictionControlParameter() {} | ||
PredictionControlParameter(std::vector<int> &&ra_features) : random_assign_features(ra_features) { | ||
// std::stable_sort(random_assign_features.begin(), random_assign_features.end(), std::less<int>()); | ||
} | ||
|
||
/*! | ||
* \brief try to enable random assignment mechanism with the split feature of current node | ||
* \param split_feat_idx real index of the split feature | ||
*/ | ||
inline bool EnableRandomAssign(int split_feat_idx) const { | ||
// return std::binary_search(random_assign_features.begin(), random_assign_features.end(), split_feat_idx); | ||
return (std::find(random_assign_features.begin(), random_assign_features.end(), split_feat_idx) | ||
!= random_assign_features.end()); | ||
} | ||
|
||
std::vector<int> random_assign_features; | ||
}; | ||
|
||
} // namespace LightGBM | ||
|
||
#endif // LIGHTGBM_PREDICTION_CONTROL_PARAMETER_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
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.