from autoxgb import AutoXGB
# Input tabular data and output artifacts
train_filename = "binary_classification.csv"
output = "output"
# optional parameters
test_filename = None
task = None
idx = None
targets = ["income"]
features = None
categorical_features = None
use_gpu = False
num_folds = 5
seed = 42
num_trials = 100
time_limit = 360
fast = False
axgb = AutoXGB(
train_filename=train_filename,
output=output,
test_filename=test_filename,
task=task,
idx=idx,
targets=targets,
features=features,
categorical_features=categorical_features,
use_gpu=use_gpu,
num_folds=num_folds,
seed=seed,
num_trials=num_trials,
time_limit=time_limit,
fast=fast,
)
axgb.train()
2022-02-09 17:36:52.310 | INFO | autoxgb.autoxgb:__post_init__:42 - Output directory: output
2022-02-09 17:36:52.311 | WARNING | autoxgb.autoxgb:__post_init__:49 - No id column specified. Will default to `id`.
2022-02-09 17:36:52.314 | INFO | autoxgb.autoxgb:_process_data:149 - Reading training data
2022-02-09 17:36:52.403 | INFO | autoxgb.utils:reduce_memory_usage:48 - Mem. usage decreased to 2.64 Mb (29.2% reduction)
2022-02-09 17:36:52.427 | INFO | autoxgb.autoxgb:_determine_problem_type:140 - Problem type: binary_classification
2022-02-09 17:36:52.428 | INFO | autoxgb.autoxgb:_create_folds:58 - Creating folds
2022-02-09 17:36:52.472 | INFO | autoxgb.autoxgb:_process_data:170 - Encoding target(s)
2022-02-09 17:36:52.486 | INFO | autoxgb.autoxgb:_process_data:195 - Found 8 categorical features.
2022-02-09 17:36:52.490 | INFO | autoxgb.autoxgb:_process_data:198 - Encoding categorical features
2022-02-09 17:36:53.034 | INFO | autoxgb.autoxgb:_process_data:236 - Model config: train_filename='binary_classification.csv' test_filename=None idx='id' targets=['income'] problem_type=<ProblemType.binary_classification: 1> output='output' features=['age', 'workclass', 'fnlwgt', 'education', 'education.num', 'marital.status', 'occupation', 'relationship', 'race', 'sex', 'capital.gain', 'capital.loss', 'hours.per.week', 'native.country'] num_folds=5 use_gpu=False seed=42 categorical_features=['workclass', 'education', 'marital.status', 'occupation', 'relationship', 'race', 'sex', 'native.country'] num_trials=100 time_limit=360 fast=False
2022-02-09 17:36:53.035 | INFO | autoxgb.autoxgb:_process_data:237 - Saving model config
2022-02-09 17:36:53.043 | INFO | autoxgb.autoxgb:_process_data:241 - Saving encoders
[I 2022-02-09 17:36:53,373] A new study created in RDB with name: autoxgb
[17:36:54] WARNING: ../src/learner.cc:576:
Parameters: { "colsample_bytree", "max_depth", "subsample", "tree_method" } might not be used.
This could be a false alarm, with some parameters getting used by language bindings but
then being mistakenly passed down to XGBoost core, or some parameter actually being used
but getting flagged wrongly here. Please open an issue if you find any such cases.
[17:40:28] WARNING: ../src/learner.cc:576:
Parameters: { "colsample_bytree", "max_depth", "subsample", "tree_method" } might not be used.
This could be a false alarm, with some parameters getting used by language bindings but
then being mistakenly passed down to XGBoost core, or some parameter actually being used
but getting flagged wrongly here. Please open an issue if you find any such cases.
[17:43:51] WARNING: ../src/learner.cc:576:
Parameters: { "colsample_bytree", "max_depth", "subsample", "tree_method" } might not be used.
This could be a false alarm, with some parameters getting used by language bindings but
then being mistakenly passed down to XGBoost core, or some parameter actually being used
but getting flagged wrongly here. Please open an issue if you find any such cases.
[17:47:12] WARNING: ../src/learner.cc:576:
Parameters: { "colsample_bytree", "max_depth", "subsample", "tree_method" } might not be used.
This could be a false alarm, with some parameters getting used by language bindings but
then being mistakenly passed down to XGBoost core, or some parameter actually being used
but getting flagged wrongly here. Please open an issue if you find any such cases.
[17:50:28] WARNING: ../src/learner.cc:576:
Parameters: { "colsample_bytree", "max_depth", "subsample", "tree_method" } might not be used.
This could be a false alarm, with some parameters getting used by language bindings but
then being mistakenly passed down to XGBoost core, or some parameter actually being used
but getting flagged wrongly here. Please open an issue if you find any such cases.
2022-02-09 17:53:44.358 | INFO | autoxgb.utils:optimize:192 - Metrics: {'auc': 0.8515864262823316, 'logloss': 0.3868649856836543, 'f1': 0.5351485750859325, 'accuracy': 0.8230396087432015, 'precision': 0.7282822005864846, 'recall': 0.42303153575005525}
[I 2022-02-09 17:53:44,509] Trial 0 finished with value: 0.3868649856836543 and parameters: {'learning_rate': 0.03456865625078672, 'reg_lambda': 2.2769738947690841e-07, 'reg_alpha': 0.006720213271638041, 'subsample': 0.6602398119145353, 'colsample_bytree': 0.7758360189887558, 'max_depth': 6, 'early_stopping_rounds': 286, 'n_estimators': 7000, 'tree_method': 'approx', 'booster': 'gblinear'}. Best is trial 0 with value: 0.3868649856836543.
2022-02-09 17:53:44.545 | INFO | autoxgb.autoxgb:train:248 - Training complete
2022-02-09 17:53:44.547 | INFO | autoxgb.autoxgb:predict:252 - Creating OOF and test predictions
2022-02-09 17:53:44.550 | INFO | autoxgb.utils:predict_model:238 - Training and predicting for fold 0
[17:53:44] WARNING: ../src/learner.cc:576:
Parameters: { "colsample_bytree", "max_depth", "subsample", "tree_method" } might not be used.
This could be a false alarm, with some parameters getting used by language bindings but
then being mistakenly passed down to XGBoost core, or some parameter actually being used
but getting flagged wrongly here. Please open an issue if you find any such cases.
2022-02-09 17:57:07.674 | INFO | autoxgb.utils:predict_model:333 - Fold 0 done!
2022-02-09 17:57:07.677 | INFO | autoxgb.utils:predict_model:238 - Training and predicting for fold 1
[17:57:07] WARNING: ../src/learner.cc:576:
Parameters: { "colsample_bytree", "max_depth", "subsample", "tree_method" } might not be used.
This could be a false alarm, with some parameters getting used by language bindings but
then being mistakenly passed down to XGBoost core, or some parameter actually being used
but getting flagged wrongly here. Please open an issue if you find any such cases.
2022-02-09 18:00:40.616 | INFO | autoxgb.utils:predict_model:333 - Fold 1 done!
2022-02-09 18:00:40.622 | INFO | autoxgb.utils:predict_model:238 - Training and predicting for fold 2
[18:00:40] WARNING: ../src/learner.cc:576:
Parameters: { "colsample_bytree", "max_depth", "subsample", "tree_method" } might not be used.
This could be a false alarm, with some parameters getting used by language bindings but
then being mistakenly passed down to XGBoost core, or some parameter actually being used
but getting flagged wrongly here. Please open an issue if you find any such cases.
2022-02-09 18:04:11.459 | INFO | autoxgb.utils:predict_model:333 - Fold 2 done!
2022-02-09 18:04:11.460 | INFO | autoxgb.utils:predict_model:238 - Training and predicting for fold 3
[18:04:11] WARNING: ../src/learner.cc:576:
Parameters: { "colsample_bytree", "max_depth", "subsample", "tree_method" } might not be used.
This could be a false alarm, with some parameters getting used by language bindings but
then being mistakenly passed down to XGBoost core, or some parameter actually being used
but getting flagged wrongly here. Please open an issue if you find any such cases.
2022-02-09 18:07:48.436 | INFO | autoxgb.utils:predict_model:333 - Fold 3 done!
2022-02-09 18:07:48.442 | INFO | autoxgb.utils:predict_model:238 - Training and predicting for fold 4
[18:07:48] WARNING: ../src/learner.cc:576:
Parameters: { "colsample_bytree", "max_depth", "subsample", "tree_method" } might not be used.
This could be a false alarm, with some parameters getting used by language bindings but
then being mistakenly passed down to XGBoost core, or some parameter actually being used
but getting flagged wrongly here. Please open an issue if you find any such cases.
2022-02-09 18:11:27.161 | INFO | autoxgb.utils:predict_model:333 - Fold 4 done!
2022-02-09 18:11:27.163 | INFO | autoxgb.utils:predict_model:336 - Metrics: {'auc': 0.851585935958628, 'logloss': 0.3868651767621002, 'f1': 0.5351485750859325, 'accuracy': 0.8230396087432015, 'precision': 0.7282822005864846, 'recall': 0.42303153575005525}
2022-02-09 18:11:27.400 | INFO | autoxgb.utils:predict_model:342 - No test data supplied. Only OOF predictions were generated
!autoxgb serve --model_path /work/output --host 0.0.0.0 --port 8080 --debug
INFO: Will watch for changes in these directories: ['/work']
INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
INFO: Started reloader process [153] using watchgod
INFO: Started server process [163]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: 172.3.167.43:41136 - "GET /favicon.ico HTTP/1.1" 404 Not Found
INFO: 172.3.167.43:41278 - "GET / HTTP/1.1" 404 Not Found
INFO: 172.3.188.123:38366 - "GET /doc HTTP/1.1" 404 Not Found
INFO: 172.3.161.55:40498 - "GET /doc HTTP/1.1" 404 Not Found
INFO: 172.3.161.55:40628 - "GET /docs HTTP/1.1" 200 OK
INFO: 172.3.188.123:38788 - "GET /openapi.json HTTP/1.1" 200 OK
INFO: 172.3.167.43:48326 - "GET /docs HTTP/1.1" 200 OK
INFO: 172.3.161.55:47018 - "GET /openapi.json HTTP/1.1" 200 OK
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
INFO: 172.3.167.43:38678 - "POST /predict HTTP/1.1" 200 OK
INFO: 172.3.188.123:51408 - "GET / HTTP/1.1" 404 Not Found
INFO: 172.3.161.55:54290 - "GET / HTTP/1.1" 404 Not Found
INFO: 172.3.161.55:54294 - "POST /predict/ HTTP/1.1" 307 Temporary Redirect
INFO: 172.3.167.43:55632 - "GET /predict HTTP/1.1" 405 Method Not Allowed
INFO: 172.3.167.43:58376 - "POST /predict/ HTTP/1.1" 307 Temporary Redirect
INFO: 172.3.161.55:57048 - "GET /predict HTTP/1.1" 405 Method Not Allowed
INFO: 172.3.167.43:58782 - "GET /predict/ HTTP/1.1" 307 Temporary Redirect
INFO: 172.3.161.55:57508 - "GET /predict HTTP/1.1" 405 Method Not Allowed
INFO: 172.3.188.123:56730 - "POST /predict/ HTTP/1.1" 307 Temporary Redirect
INFO: 172.3.161.55:58616 - "GET /predict HTTP/1.1" 405 Method Not Allowed
INFO: 172.3.161.55:59288 - "POST /predict/ HTTP/1.1" 307 Temporary Redirect
INFO: 172.3.167.43:60628 - "GET /predict HTTP/1.1" 405 Method Not Allowed
INFO: 172.3.188.123:58756 - "POST /predict/ HTTP/1.1" 307 Temporary Redirect
INFO: 172.3.188.123:58760 - "GET /predict HTTP/1.1" 405 Method Not Allowed
INFO: 172.3.167.43:34424 - "GET /docs/predict HTTP/1.1" 404 Not Found
INFO: 172.3.188.123:59578 - "GET /docs/ HTTP/1.1" 307 Temporary Redirect
INFO: 172.3.167.43:34576 - "GET /docs HTTP/1.1" 200 OK
INFO: 172.3.167.43:34616 - "GET /openapi.json HTTP/1.1" 200 OK
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
INFO: 172.3.167.43:35520 - "POST /predict HTTP/1.1" 200 OK
INFO: 172.3.188.123:35358 - "POST /predict HTTP/1.1" 422 Unprocessable Entity
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
/root/venv/lib/python3.8/site-packages/autoxgb/predict.py:60: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test_features[col] = test_features[col].astype(np.int64)
INFO: 172.3.167.43:39118 - "POST /predict HTTP/1.1" 200 OK
^C
INFO: Shutting down
INFO: Finished server process [163]
ERROR: Traceback (most recent call last):
File "/root/venv/lib/python3.8/site-packages/starlette/routing.py", line 624, in lifespan
await receive()
File "/root/venv/lib/python3.8/site-packages/uvicorn/lifespan/on.py", line 135, in receive
return await self.receive_queue.get()
File "/usr/local/lib/python3.8/asyncio/queues.py", line 163, in get
await getter
asyncio.exceptions.CancelledError
import requests
params = {
"workclass": "Private",
"education": "HS-grad",
"marital.status": "Widowed",
"occupation": "Transport-moving",
"relationship": "Unmarried",
"race": "White",
"sex": "Male",
"native.country": "United-States",
"age": 20,
"fnlwgt": 313986,
"education.num": 9,
"capital.gain": 0,
"capital.loss": 0,
"hours.per.week": 40,
}
article = requests.post(
f"https://8d3ae411-c6bc-4cad-8a14-732f8e3f13b7.deepnoteproject.com/predict",
json=params,
)
data_dict = article.json()
print(data_dict)
## {'id': 0, '<=50K': 0.9762147068977356, '>50K': 0.023785298690199852}