forked from microsoft/qlib
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request microsoft#444 from zhupr/feature_importance
add get_feature_importance to model interpret
- Loading branch information
Showing
26 changed files
with
592 additions
and
822 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
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,32 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
|
||
import qlib | ||
from qlib.config import REG_CN | ||
|
||
from qlib.utils import init_instance_by_config | ||
from qlib.tests.data import GetData | ||
from qlib.tests.config import CSI300_GBDT_TASK | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
# use default data | ||
provider_uri = "~/.qlib/qlib_data/cn_data" # target_dir | ||
GetData().qlib_data(target_dir=provider_uri, region=REG_CN, exists_skip=True) | ||
|
||
qlib.init(provider_uri=provider_uri, region=REG_CN) | ||
|
||
################################### | ||
# train model | ||
################################### | ||
# model initialization | ||
model = init_instance_by_config(CSI300_GBDT_TASK["model"]) | ||
dataset = init_instance_by_config(CSI300_GBDT_TASK["dataset"]) | ||
model.fit(dataset) | ||
|
||
# get model feature importance | ||
feature_importance = model.get_feature_importance() | ||
print("feature importance:") | ||
print(feature_importance) |
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.