You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Default-Flamlized.md 4.0 kB

Refactor into automl subpackage (#809) * Refactor into automl subpackage Moved some of the packages into an automl subpackage to tidy before the task-based refactor. This is in response to discussions with the group and a comment on the first task-based PR. Only changes here are moving subpackages and modules into the new automl, fixing imports to work with this structure and fixing some dependencies in setup.py. * Fix doc building post automl subpackage refactor * Fix broken links in website post automl subpackage refactor * Fix broken links in website post automl subpackage refactor * Remove vw from test deps as this is breaking the build * Move default back to the top-level I'd moved this to automl as that's where it's used internally, but had missed that this is actually part of the public interface so makes sense to live where it was. * Re-add top level modules with deprecation warnings flaml.data, flaml.ml and flaml.model are re-added to the top level, being re-exported from flaml.automl for backwards compatability. Adding a deprecation warning so that we can have a planned removal later. * Fix model.py line-endings * Pin pytorch-lightning to less than 1.8.0 We're seeing strange lightning related bugs from pytorch-forecasting since the release of lightning 1.8.0. Going to try constraining this to see if we have a fix. * Fix the lightning version pin Was optimistic with setting it in the 1.7.x range, but that isn't compatible with python 3.6 * Remove lightning version pin * Revert dependency version changes * Minor change to retrigger the build * Fix line endings in ml.py and model.py Co-authored-by: Qingyun Wu <qingyun.wu@psu.edu> Co-authored-by: EgorKraevTransferwise <egor.kraev@transferwise.com>
3 years ago
Refactor into automl subpackage (#809) * Refactor into automl subpackage Moved some of the packages into an automl subpackage to tidy before the task-based refactor. This is in response to discussions with the group and a comment on the first task-based PR. Only changes here are moving subpackages and modules into the new automl, fixing imports to work with this structure and fixing some dependencies in setup.py. * Fix doc building post automl subpackage refactor * Fix broken links in website post automl subpackage refactor * Fix broken links in website post automl subpackage refactor * Remove vw from test deps as this is breaking the build * Move default back to the top-level I'd moved this to automl as that's where it's used internally, but had missed that this is actually part of the public interface so makes sense to live where it was. * Re-add top level modules with deprecation warnings flaml.data, flaml.ml and flaml.model are re-added to the top level, being re-exported from flaml.automl for backwards compatability. Adding a deprecation warning so that we can have a planned removal later. * Fix model.py line-endings * Pin pytorch-lightning to less than 1.8.0 We're seeing strange lightning related bugs from pytorch-forecasting since the release of lightning 1.8.0. Going to try constraining this to see if we have a fix. * Fix the lightning version pin Was optimistic with setting it in the 1.7.x range, but that isn't compatible with python 3.6 * Remove lightning version pin * Revert dependency version changes * Minor change to retrigger the build * Fix line endings in ml.py and model.py Co-authored-by: Qingyun Wu <qingyun.wu@psu.edu> Co-authored-by: EgorKraevTransferwise <egor.kraev@transferwise.com>
3 years ago
Refactor into automl subpackage (#809) * Refactor into automl subpackage Moved some of the packages into an automl subpackage to tidy before the task-based refactor. This is in response to discussions with the group and a comment on the first task-based PR. Only changes here are moving subpackages and modules into the new automl, fixing imports to work with this structure and fixing some dependencies in setup.py. * Fix doc building post automl subpackage refactor * Fix broken links in website post automl subpackage refactor * Fix broken links in website post automl subpackage refactor * Remove vw from test deps as this is breaking the build * Move default back to the top-level I'd moved this to automl as that's where it's used internally, but had missed that this is actually part of the public interface so makes sense to live where it was. * Re-add top level modules with deprecation warnings flaml.data, flaml.ml and flaml.model are re-added to the top level, being re-exported from flaml.automl for backwards compatability. Adding a deprecation warning so that we can have a planned removal later. * Fix model.py line-endings * Pin pytorch-lightning to less than 1.8.0 We're seeing strange lightning related bugs from pytorch-forecasting since the release of lightning 1.8.0. Going to try constraining this to see if we have a fix. * Fix the lightning version pin Was optimistic with setting it in the 1.7.x range, but that isn't compatible with python 3.6 * Remove lightning version pin * Revert dependency version changes * Minor change to retrigger the build * Fix line endings in ml.py and model.py Co-authored-by: Qingyun Wu <qingyun.wu@psu.edu> Co-authored-by: EgorKraevTransferwise <egor.kraev@transferwise.com>
3 years ago
Refactor into automl subpackage (#809) * Refactor into automl subpackage Moved some of the packages into an automl subpackage to tidy before the task-based refactor. This is in response to discussions with the group and a comment on the first task-based PR. Only changes here are moving subpackages and modules into the new automl, fixing imports to work with this structure and fixing some dependencies in setup.py. * Fix doc building post automl subpackage refactor * Fix broken links in website post automl subpackage refactor * Fix broken links in website post automl subpackage refactor * Remove vw from test deps as this is breaking the build * Move default back to the top-level I'd moved this to automl as that's where it's used internally, but had missed that this is actually part of the public interface so makes sense to live where it was. * Re-add top level modules with deprecation warnings flaml.data, flaml.ml and flaml.model are re-added to the top level, being re-exported from flaml.automl for backwards compatability. Adding a deprecation warning so that we can have a planned removal later. * Fix model.py line-endings * Pin pytorch-lightning to less than 1.8.0 We're seeing strange lightning related bugs from pytorch-forecasting since the release of lightning 1.8.0. Going to try constraining this to see if we have a fix. * Fix the lightning version pin Was optimistic with setting it in the 1.7.x range, but that isn't compatible with python 3.6 * Remove lightning version pin * Revert dependency version changes * Minor change to retrigger the build * Fix line endings in ml.py and model.py Co-authored-by: Qingyun Wu <qingyun.wu@psu.edu> Co-authored-by: EgorKraevTransferwise <egor.kraev@transferwise.com>
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # Default - Flamlized Estimator
  2. Flamlized estimators automatically use data-dependent default hyperparameter configurations for each estimator, offering a unique zero-shot AutoML capability, or "no tuning" AutoML.
  3. ## Flamlized LGBMRegressor
  4. ### Prerequisites
  5. This example requires the [autozero] option.
  6. ```bash
  7. pip install flaml[autozero] lightgbm openml
  8. ```
  9. ### Zero-shot AutoML
  10. ```python
  11. from flaml.automl.data import load_openml_dataset
  12. from flaml.default import LGBMRegressor
  13. from flaml.automl.ml import sklearn_metric_loss_score
  14. X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id=537, data_dir="./")
  15. lgbm = LGBMRegressor()
  16. lgbm.fit(X_train, y_train)
  17. y_pred = lgbm.predict(X_test)
  18. print("flamlized lgbm r2", "=", 1 - sklearn_metric_loss_score("r2", y_pred, y_test))
  19. print(lgbm)
  20. ```
  21. #### Sample output
  22. ```
  23. load dataset from ./openml_ds537.pkl
  24. Dataset name: houses
  25. X_train.shape: (15480, 8), y_train.shape: (15480,);
  26. X_test.shape: (5160, 8), y_test.shape: (5160,)
  27. flamlized lgbm r2 = 0.8537444671194614
  28. LGBMRegressor(colsample_bytree=0.7019911744574896,
  29. learning_rate=0.022635758411078528, max_bin=511,
  30. min_child_samples=2, n_estimators=4797, num_leaves=122,
  31. reg_alpha=0.004252223402511765, reg_lambda=0.11288241427227624,
  32. verbose=-1)
  33. ```
  34. ### Suggest hyperparameters without training
  35. ```
  36. from flaml.data import load_openml_dataset
  37. from flaml.default import LGBMRegressor
  38. from flaml.ml import sklearn_metric_loss_score
  39. X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id=537, data_dir="./")
  40. lgbm = LGBMRegressor()
  41. hyperparams, estimator_name, X_transformed, y_transformed = lgbm.suggest_hyperparams(X_train, y_train)
  42. print(hyperparams)
  43. ```
  44. #### Sample output
  45. ```
  46. load dataset from ./openml_ds537.pkl
  47. Dataset name: houses
  48. X_train.shape: (15480, 8), y_train.shape: (15480,);
  49. X_test.shape: (5160, 8), y_test.shape: (5160,)
  50. {'n_estimators': 4797, 'num_leaves': 122, 'min_child_samples': 2, 'learning_rate': 0.022635758411078528, 'colsample_bytree': 0.7019911744574896, 'reg_alpha': 0.004252223402511765, 'reg_lambda': 0.11288241427227624, 'max_bin': 511, 'verbose': -1}
  51. ```
  52. [Link to notebook](https://github.com/microsoft/FLAML/blob/main/notebook/zeroshot_lightgbm.ipynb) | [Open in colab](https://colab.research.google.com/github/microsoft/FLAML/blob/main/notebook/zeroshot_lightgbm.ipynb)
  53. ## Flamlized XGBClassifier
  54. ### Prerequisites
  55. This example requires xgboost, sklearn, openml==0.10.2.
  56. ### Zero-shot AutoML
  57. ```python
  58. from flaml.automl.data import load_openml_dataset
  59. from flaml.default import XGBClassifier
  60. from flaml.automl.ml import sklearn_metric_loss_score
  61. X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id=1169, data_dir="./")
  62. xgb = XGBClassifier()
  63. xgb.fit(X_train, y_train)
  64. y_pred = xgb.predict(X_test)
  65. print("flamlized xgb accuracy", "=", 1 - sklearn_metric_loss_score("accuracy", y_pred, y_test))
  66. print(xgb)
  67. ```
  68. #### Sample output
  69. ```
  70. load dataset from ./openml_ds1169.pkl
  71. Dataset name: airlines
  72. X_train.shape: (404537, 7), y_train.shape: (404537,);
  73. X_test.shape: (134846, 7), y_test.shape: (134846,)
  74. flamlized xgb accuracy = 0.6729009388487608
  75. XGBClassifier(base_score=0.5, booster='gbtree',
  76. colsample_bylevel=0.4601573737792679, colsample_bynode=1,
  77. colsample_bytree=1.0, gamma=0, gpu_id=-1, grow_policy='lossguide',
  78. importance_type='gain', interaction_constraints='',
  79. learning_rate=0.04039771837785377, max_delta_step=0, max_depth=0,
  80. max_leaves=159, min_child_weight=0.3396294979905001, missing=nan,
  81. monotone_constraints='()', n_estimators=540, n_jobs=4,
  82. num_parallel_tree=1, random_state=0,
  83. reg_alpha=0.0012362430984376035, reg_lambda=3.093428791531145,
  84. scale_pos_weight=1, subsample=1.0, tree_method='hist',
  85. use_label_encoder=False, validate_parameters=1, verbosity=0)
  86. ```