forked from dmlc/xgboost
-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
fab3c05
commit a3d195e
Showing
4 changed files
with
93 additions
and
5 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,26 @@ | ||
import os | ||
import xgboost as xgb | ||
from sklearn.datasets import make_classification | ||
from sklearn.metrics import roc_auc_score | ||
import sys | ||
|
||
|
||
def run_omp(output_path: str): | ||
X, y = make_classification( | ||
n_samples=200, n_features=32, n_classes=3, n_informative=8 | ||
) | ||
Xy = xgb.DMatrix(X, y, nthread=16) | ||
booster = xgb.train( | ||
{"num_class": 3, "objective": "multi:softprob", "n_jobs": 16}, | ||
Xy, | ||
num_boost_round=8, | ||
) | ||
score = booster.predict(Xy) | ||
auc = roc_auc_score(y, score, average="weighted", multi_class="ovr") | ||
with open(output_path, "w") as fd: | ||
fd.write(str(auc)) | ||
|
||
|
||
if __name__ == "__main__": | ||
out = sys.argv[1] | ||
run_omp(out) |