MCPcopy Create free account
hub / github.com/dmlc/xgboost / run_sklearn_api

Function run_sklearn_api

tests/python/test_with_sklearn.py:573–588  ·  view source on GitHub ↗
(booster, error, n_est)

Source from the content-addressed store, hash-verified

571
572
573def run_sklearn_api(booster, error, n_est):
574 from sklearn.datasets import load_iris
575 from sklearn.model_selection import train_test_split
576
577 iris = load_iris()
578 tr_d, te_d, tr_l, te_l = train_test_split(
579 iris.data, iris.target, train_size=120, test_size=0.2
580 )
581
582 classifier = xgb.XGBClassifier(booster=booster, n_estimators=n_est)
583 classifier.fit(tr_d, tr_l)
584
585 preds = classifier.predict(te_d)
586 labels = te_l
587 err = sum([1 for p, l in zip(preds, labels) if p != l]) * 1.0 / len(te_l)
588 assert err < error
589
590
591def test_sklearn_api():

Callers 1

test_sklearn_apiFunction · 0.85

Calls 2

fitMethod · 0.95
predictMethod · 0.95

Tested by

no test coverage detected