API
Supervised-training
AutoML class
Bases: BaseAutoML
Automated Machine Learning for supervised tasks (binary classification, multiclass classification, regression).
Source code in supervised\automl.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
|
__init__(results_path=None, total_time_limit=60 * 60, mode='Explain', ml_task='auto', model_time_limit=None, algorithms='auto', train_ensemble=True, stack_models='auto', eval_metric='auto', validation_strategy='auto', explain_level='auto', composite_features='auto', features_selection='auto', start_random_models='auto', hill_climbing_steps='auto', top_models_to_improve='auto', boost_on_errors='auto', kmeans_features='auto', mix_encoding='auto', max_single_prediction_time=None, optuna_time_budget=None, optuna_init_params={}, optuna_verbose=True, fairness_metric='auto', fairness_threshold='auto', privileged_groups='auto', underprivileged_groups='auto', n_jobs=-1, verbose=1, random_state=1234, self_training=False)
Initialize AutoML
object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results_path |
str
|
The path with results.
If None, then the name of directory will be generated with the template: AutoML_{number},
where the number can be from 1 to 1,000 - depends which direcory name will be available.
If the |
None
|
total_time_limit |
int
|
The total time limit in seconds for AutoML training.
It is not used when |
60 * 60
|
mode |
str
|
Can be {
|
'Explain'
|
ml_task |
str
|
Can be {"auto", "binary_classification", "multiclass_classification", "regression"}.
|
'auto'
|
model_time_limit |
int
|
The time limit for training a single model, in seconds.
If For example, in the case of 10-fold cross-validation, one model will have 10 learners.
The |
None
|
algorithms |
list of str
|
The list of algorithms that will be used in the training. The algorithms can be:
|
'auto'
|
train_ensemble |
boolean
|
Whether an ensemble gets created at the end of the training. |
True
|
stack_models |
boolean
|
Whether a models stack gets created at the end of the training. Stack level is 1. |
'auto'
|
eval_metric |
str
|
The metric to be used in early stopping and to compare models.
|
'auto'
|
validation_strategy |
dict
|
Dictionary with validation type. Train/test split and cross-validation are supported. |
'auto'
|
explain_level |
int
|
The level of explanations included to each model:
If left |
'auto'
|
composite_features |
boolean or int
|
Whether to use golden features (and how many should be added)
If left
If If |
'auto'
|
features_selection |
boolean
|
Whether to do features_selection
If left
|
'auto'
|
start_random_models |
int
|
Number of starting random models to try.
If left
|
'auto'
|
hill_climbing_steps |
int
|
Number of steps to perform during hill climbing.
If left
|
'auto'
|
top_models_to_improve |
int
|
Number of best models to improve in
|
'auto'
|
boost_on_errors |
boolean
|
Whether a model with boost on errors from previous best model should be trained. By default available in the |
'auto'
|
kmeans_features |
boolean
|
Whether a model with k-means generated features should be trained. By default available in the |
'auto'
|
mix_encoding |
boolean
|
Whether a model with mixed encoding should be trained. Mixed encoding is the encoding that uses label encoding
for categoricals with more than 25 categories, and one-hot binary encoding for other categoricals. It is only applied if there are
categorical features with cardinality smaller than 25. By default it is available in the |
'auto'
|
max_single_prediction_time |
int or float
|
The limit for prediction time for single sample. Use it if you want to have a model with fast predictions.
Ideal for creating ML pipelines used as REST API. Time is in seconds. By default ( |
None
|
optuna_time_budget |
int
|
The time in seconds which should be used by Optuna to tune each algorithm. It is time for tuning single algorithm.
If you select two algorithms: Xgboost and CatBoost, and set optuna_time_budget=1000, then Xgboost will be tuned for 1000 seconds and CatBoost will be tuned for 1000 seconds.
What is more, the tuning is made for each data type, for example for raw data and for data with inserted Golden Features.
This parameter is only used when |
None
|
optuna_init_params |
dict
|
If you have already tuned parameters from Optuna you can reuse them by setting this parameter.
This parameter is only used when |
{}
|
optuna_verbose |
boolean
|
If true the Optuna tuning details are displayed. Set to |
True
|
fairness_metric |
string
|
Name of fairness metric that will be used for assessing fairness criteria. Available metrics for binary and multiclass classification:
Metrics for regression:
|
'auto'
|
fairness_threshold |
float
|
The treshold value for fairness metric. The direction optimization (below or above threshold) of fairness metric is determined automatically. Default values:
For |
'auto'
|
privileged_groups |
list
|
The list of privileged groups. By default, list of privileged groups are automatically detected based on fairness metrics. For example, in binary classification task, a privileged group is the one with the highest selection rate. Example value: |
'auto'
|
underprivileged_groups |
list
|
The list of underprivileged groups. By default, list of underprivileged groups are automatically detected based on fairness metrics. For example, in binary classification task, an underprivileged group is the one with the lowest selection rate. Example value: |
'auto'
|
n_jobs |
int
|
Number of CPU cores to be used. Default is set to |
-1
|
verbose |
int
|
Controls the verbosity when fitting and predicting. Note:
Still not implemented, please left |
1
|
random_state |
int
|
Controls the randomness of the |
1234
|
Source code in supervised\automl.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
|
fit(X, y, sample_weight=None, cv=None, sensitive_features=None)
Fit the AutoML model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
numpy.ndarray or pandas.DataFrame
|
Training data |
required |
y |
numpy.ndarray or pandas.Series
|
Training targets |
required |
sample_weight |
numpy.ndarray or pandas.Series
|
Training sample weights |
None
|
cv |
iterable or list
|
List or iterable with (train, validation) splits representing array of indices.
It is used only with custom validation ( |
None
|
sensitive_features |
numpy.ndarray or pandas.Series or pandas.DataFrame
|
Sensitive features to learn fair models |
None
|
Returns:
Type | Description |
---|---|
AutoML object: Returns |
Source code in supervised\automl.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
need_retrain(X, y, sample_weight=None, decrease=0.1)
Decides about model retraining based on new data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
numpy.ndarray or pandas.DataFrame
|
New data. |
required |
y |
numpy.ndarray or pandas.Series
|
True labels for X. |
required |
sample_weight |
numpy.ndarray or pandas.Series
|
Sample weights. |
None
|
decrease |
float
|
The ratio of change in the performance used as a threshold for retraining decision.
By default, it is set to |
0.1
|
Returns |
boolean: Decides if there is a need to retrain the AutoML. |
required |
Source code in supervised\automl.py
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
|
predict(X)
Computes predictions from AutoML best model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
list or numpy.ndarray or pandas.DataFrame
|
Input values to make predictions on. |
required |
Returns:
Type | Description |
---|---|
numpy.ndarray
|
numpy.ndarray: |
numpy.ndarray
|
|
numpy.ndarray
|
|
Source code in supervised\automl.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
|
predict_all(X)
Computes both class probabilities and class labels for classification tasks. Computes predictions for regression tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
list or numpy.ndarray or pandas.DataFrame
|
Input values to make predictions on. |
required |
Returns:
Type | Description |
---|---|
pandas.DataFrame
|
pandas.Dataframe: Dataframe (n_samples, n_classes + 1) containing both class probabilities and class labels of the input samples for classification tasks. Dataframe with predictions for regression tasks. |
Raises:
Type | Description |
---|---|
AutoMLException
|
Model has not yet been fitted. |
Source code in supervised\automl.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
predict_proba(X)
Computes class probabilities from AutoML best model. This method can only be used for classification tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
list or numpy.ndarray or pandas.DataFrame
|
Input values to make predictions on. |
required |
Returns:
Type | Description |
---|---|
numpy.ndarray
|
numpy.ndarray of shape (n_samples, n_classes): Matrix of containing class probabilities of the input samples |
Raises:
Type | Description |
---|---|
AutoMLException
|
Model has not yet been fitted. |
Source code in supervised\automl.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
|
score(X, y=None, sample_weight=None)
Calculates a goodness of fit
for an AutoML instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
numpy.ndarray or pandas.DataFrame
|
Test values to make predictions on. |
required |
y |
numpy.ndarray or pandas.Series
|
True labels for X. |
None
|
sample_weight |
numpy.ndarray or pandas.Series
|
Sample weights. |
None
|
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Returns a goodness of fit measure (higher is better): |
float
|
|
|
float
|
|
Source code in supervised\automl.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
|
ModelFramework class
Source code in supervised\model_framework.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
|
involved_model_names()
Returns the list of all models involved in the current model. For single model, it returns the list with the name of the model. For ensemble model, it returns the list with the name of the ensemble and all internal models (used to build ensemble). For single model but trained on stacked data, it returns the list with the name of the model (names of models used in stacking are not included).
Source code in supervised\model_framework.py
412 413 414 415 416 417 418 419 |
|
is_valid()
is_valid is used in Ensemble to check if it has more than 1 model in it. If Ensemble has only 1 model in it, then Ensemble shouldn't be used as best model
Source code in supervised\model_framework.py
421 422 423 424 425 |
|
Ensemble class
stack models to build level 2 ensemble.
Source code in supervised\ensemble.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
|
get_out_of_folds()
Needed when ensemble is treated as model and we want to compute additional metrics for it
Source code in supervised\ensemble.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
involved_model_names()
Returns the list of all models involved in the current model. For single model, it returns the list with the name of the model. For ensemble model, it returns the list with the name of the ensemble and all internal models (used to build ensemble). For single model but trained on stacked data, it returns the list with the name of the model (names of models used in stacking are not included).
Source code in supervised\ensemble.py
109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
Self-training
AutoST class
Automated Self-training for semi-supervised tasks.
Source code in semisupervised\autost.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|