forked from aparo/opensearch-learning-to-rank
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added demo files from elasticsearch repo to opensearch repo
Signed-off-by: JohannesDaniel <[email protected]>
- Loading branch information
1 parent
5b73729
commit 37f1e0a
Showing
5 changed files
with
83 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
This folder contains files demonstrating how to work with xgboost. | ||
|
||
## xgboost.txt | ||
The sample training data utilized in the main demo folder but in LibSVM format which is used by xgboost. | ||
|
||
## featmap.txt | ||
A configuration file telling xgboost the feature names that feature ordinals refer to. | ||
|
||
## xgb.py | ||
A bare-bones script for reading `xgboost.txt` and training a model for usage with the plugin. | ||
|
||
## xgb-model.json | ||
Included for convenience, this is the output of xgb.py, a JSON formatted model compatible with the LTR plugin. | ||
|
||
|
||
# Notes | ||
Although there are PyPI packages for xgboost, some users will find that installation fails in their local environments. If this occurs the best workaround is to clone the xgboost repository and do a local build with the latest. | ||
|
||
``` | ||
git clone --recursive https://github.com/dmlc/xgboost | ||
cd xgboost | ||
make -j4 | ||
cd python-package | ||
python setup.py install | ||
``` | ||
|
||
Note: If doing a global install you may need to run with root privileges, the above should work in a virtual environment. |
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,3 @@ | ||
0 na q | ||
1 tmdb_title q | ||
2 tmdb_multi q |
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,13 @@ | ||
[ { "nodeid": 0, "depth": 0, "split": "tmdb_multi", "split_condition": 11.2009, "yes": 1, "no": 2, "missing": 1, "children": [ | ||
{ "nodeid": 1, "depth": 1, "split": "tmdb_title", "split_condition": 2.20631, "yes": 3, "no": 4, "missing": 3, "children": [ | ||
{ "nodeid": 3, "leaf": -0.03125 }, | ||
{ "nodeid": 4, "leaf": -0.25 } | ||
]}, | ||
{ "nodeid": 2, "leaf": 2.45 } | ||
]}, { "nodeid": 0, "depth": 0, "split": "tmdb_title", "split_condition": 7.56362, "yes": 1, "no": 2, "missing": 1, "children": [ | ||
{ "nodeid": 1, "depth": 1, "split": "tmdb_multi", "split_condition": 11.2009, "yes": 3, "no": 4, "missing": 3, "children": [ | ||
{ "nodeid": 3, "leaf": -0.0165441 }, | ||
{ "nodeid": 4, "leaf": 0.04375 } | ||
]}, | ||
{ "nodeid": 2, "leaf": 0.7 } | ||
]}] |
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,15 @@ | ||
import xgboost as xgb | ||
|
||
# Read the LibSVM labels/features | ||
dtrain = xgb.DMatrix('xgboost.txt') | ||
param = {'max_depth':2, 'eta':1, 'silent':1, 'objective':'reg:linear'} | ||
num_round = 2 | ||
|
||
bst = xgb.train(param, dtrain, num_round) | ||
|
||
model = bst.get_dump(fmap='featmap.txt', dump_format='json') | ||
|
||
with open('xgb-model.json', 'w') as output: | ||
output.write('[' + ','.join(list(model)) + ']') | ||
output.close() | ||
|
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,25 @@ | ||
4 1:9.169009 2:22.169247 | ||
3 1:6.9903145 2:20.8937 | ||
3 1:4.972313 2:19.01041 | ||
3 1:0.0 2:14.370026 | ||
0 1:0.0 2:0.0 | ||
0 1:0.0 2:0.0 | ||
0 1:0.0 2:0.0 | ||
0 1:0.0 2:0.0 | ||
0 1:0.0 2:0.0 | ||
0 1:0.0 2:0.0 | ||
4 1:8.136918 2:18.368336 | ||
3 1:6.203464 2:17.696943 | ||
3 1:0.0 2:0.0 | ||
3 1:6.203464 2:14.961248 | ||
3 1:6.203464 2:16.599255 | ||
3 1:6.203464 2:17.696943 | ||
0 1:0.0 2:0.0 | ||
0 1:0.0 2:0.0 | ||
0 1:4.4126143 2:8.031729 | ||
4 1:0.0 2:0.0 | ||
0 1:0.0 2:0.0 | ||
0 1:0.0 2:0.0 | ||
0 1:0.0 2:0.0 | ||
0 1:0.0 2:0.0 | ||
0 1:0.0 2:0.0 |