@@ -67,6 +67,82 @@ X_test.shape: (5160, 8), y_test.shape: (5160,)
6767
6868[ 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 )
6969
70+ ## Flamlized LGBMClassifier
71+
72+ ### Prerequisites
73+
74+ This example requires the [ autozero] option.
75+
76+ ``` bash
77+ pip install flaml[autozero] lightgbm openml
78+ ```
79+
80+ ### Zero-shot AutoML
81+
82+ ``` python
83+ from flaml.automl.data import load_openml_dataset
84+ from flaml.default import LGBMClassifier
85+ from flaml.automl.ml import sklearn_metric_loss_score
86+
87+ X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id = 1169 , data_dir = " ./" )
88+ lgbm = LGBMClassifier()
89+ lgbm.fit(X_train, y_train)
90+ y_pred = lgbm.predict(X_test)
91+ print (
92+ " flamlized lgbm accuracy" ,
93+ " =" ,
94+ 1 - sklearn_metric_loss_score(" accuracy" , y_pred, y_test),
95+ )
96+ print (lgbm)
97+ ```
98+
99+ #### Sample output
100+
101+ ```
102+ load dataset from ./openml_ds1169.pkl
103+ Dataset name: airlines
104+ X_train.shape: (404537, 7), y_train.shape: (404537,);
105+ X_test.shape: (134846, 7), y_test.shape: (134846,)
106+ flamlized lgbm accuracy = 0.6745
107+ LGBMClassifier(colsample_bytree=0.85, learning_rate=0.05, max_bin=255,
108+ min_child_samples=20, n_estimators=500, num_leaves=31,
109+ reg_alpha=0.01, reg_lambda=0.1, verbose=-1)
110+ ```
111+
112+ ## Flamlized XGBRegressor
113+
114+ ### Prerequisites
115+
116+ This example requires xgboost, sklearn, openml==0.10.2.
117+
118+ ### Zero-shot AutoML
119+
120+ ``` python
121+ from flaml.automl.data import load_openml_dataset
122+ from flaml.default import XGBRegressor
123+ from flaml.automl.ml import sklearn_metric_loss_score
124+
125+ X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id = 537 , data_dir = " ./" )
126+ xgb = XGBRegressor()
127+ xgb.fit(X_train, y_train)
128+ y_pred = xgb.predict(X_test)
129+ print (" flamlized xgb r2" , " =" , 1 - sklearn_metric_loss_score(" r2" , y_pred, y_test))
130+ print (xgb)
131+ ```
132+
133+ #### Sample output
134+
135+ ```
136+ load dataset from ./openml_ds537.pkl
137+ Dataset name: houses
138+ X_train.shape: (15480, 8), y_train.shape: (15480,);
139+ X_test.shape: (5160, 8), y_test.shape: (5160,)
140+ flamlized xgb r2 = 0.8542
141+ XGBRegressor(colsample_bylevel=1, colsample_bytree=0.85, learning_rate=0.05,
142+ max_depth=6, n_estimators=500, reg_alpha=0.01, reg_lambda=1.0,
143+ subsample=0.9)
144+ ```
145+
70146## Flamlized XGBClassifier
71147
72148### Prerequisites
@@ -112,3 +188,159 @@ XGBClassifier(base_score=0.5, booster='gbtree',
112188 scale_pos_weight=1, subsample=1.0, tree_method='hist',
113189 use_label_encoder=False, validate_parameters=1, verbosity=0)
114190```
191+
192+ ## Flamlized RandomForestRegressor
193+
194+ ### Prerequisites
195+
196+ This example requires the [ autozero] option.
197+
198+ ``` bash
199+ pip install flaml[autozero] scikit-learn openml
200+ ```
201+
202+ ### Zero-shot AutoML
203+
204+ ``` python
205+ from flaml.automl.data import load_openml_dataset
206+ from flaml.default import RandomForestRegressor
207+ from flaml.automl.ml import sklearn_metric_loss_score
208+
209+ X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id = 537 , data_dir = " ./" )
210+ rf = RandomForestRegressor()
211+ rf.fit(X_train, y_train)
212+ y_pred = rf.predict(X_test)
213+ print (" flamlized rf r2" , " =" , 1 - sklearn_metric_loss_score(" r2" , y_pred, y_test))
214+ print (rf)
215+ ```
216+
217+ #### Sample output
218+
219+ ```
220+ load dataset from ./openml_ds537.pkl
221+ Dataset name: houses
222+ X_train.shape: (15480, 8), y_train.shape: (15480,);
223+ X_test.shape: (5160, 8), y_test.shape: (5160,)
224+ flamlized rf r2 = 0.8521
225+ RandomForestRegressor(max_features=0.8, min_samples_leaf=2, min_samples_split=5,
226+ n_estimators=500)
227+ ```
228+
229+ ## Flamlized RandomForestClassifier
230+
231+ ### Prerequisites
232+
233+ This example requires the [ autozero] option.
234+
235+ ``` bash
236+ pip install flaml[autozero] scikit-learn openml
237+ ```
238+
239+ ### Zero-shot AutoML
240+
241+ ``` python
242+ from flaml.automl.data import load_openml_dataset
243+ from flaml.default import RandomForestClassifier
244+ from flaml.automl.ml import sklearn_metric_loss_score
245+
246+ X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id = 1169 , data_dir = " ./" )
247+ rf = RandomForestClassifier()
248+ rf.fit(X_train, y_train)
249+ y_pred = rf.predict(X_test)
250+ print (
251+ " flamlized rf accuracy" ,
252+ " =" ,
253+ 1 - sklearn_metric_loss_score(" accuracy" , y_pred, y_test),
254+ )
255+ print (rf)
256+ ```
257+
258+ #### Sample output
259+
260+ ```
261+ load dataset from ./openml_ds1169.pkl
262+ Dataset name: airlines
263+ X_train.shape: (404537, 7), y_train.shape: (404537,);
264+ X_test.shape: (134846, 7), y_test.shape: (134846,)
265+ flamlized rf accuracy = 0.6701
266+ RandomForestClassifier(max_features=0.7, min_samples_leaf=3, min_samples_split=5,
267+ n_estimators=500)
268+ ```
269+
270+ ## Flamlized ExtraTreesRegressor
271+
272+ ### Prerequisites
273+
274+ This example requires the [ autozero] option.
275+
276+ ``` bash
277+ pip install flaml[autozero] scikit-learn openml
278+ ```
279+
280+ ### Zero-shot AutoML
281+
282+ ``` python
283+ from flaml.automl.data import load_openml_dataset
284+ from flaml.default import ExtraTreesRegressor
285+ from flaml.automl.ml import sklearn_metric_loss_score
286+
287+ X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id = 537 , data_dir = " ./" )
288+ et = ExtraTreesRegressor()
289+ et.fit(X_train, y_train)
290+ y_pred = et.predict(X_test)
291+ print (" flamlized et r2" , " =" , 1 - sklearn_metric_loss_score(" r2" , y_pred, y_test))
292+ print (et)
293+ ```
294+
295+ #### Sample output
296+
297+ ```
298+ load dataset from ./openml_ds537.pkl
299+ Dataset name: houses
300+ X_train.shape: (15480, 8), y_train.shape: (15480,);
301+ X_test.shape: (5160, 8), y_test.shape: (5160,)
302+ flamlized et r2 = 0.8534
303+ ExtraTreesRegressor(max_features=0.75, min_samples_leaf=2, min_samples_split=5,
304+ n_estimators=500)
305+ ```
306+
307+ ## Flamlized ExtraTreesClassifier
308+
309+ ### Prerequisites
310+
311+ This example requires the [ autozero] option.
312+
313+ ``` bash
314+ pip install flaml[autozero] scikit-learn openml
315+ ```
316+
317+ ### Zero-shot AutoML
318+
319+ ``` python
320+ from flaml.automl.data import load_openml_dataset
321+ from flaml.default import ExtraTreesClassifier
322+ from flaml.automl.ml import sklearn_metric_loss_score
323+
324+ X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id = 1169 , data_dir = " ./" )
325+ et = ExtraTreesClassifier()
326+ et.fit(X_train, y_train)
327+ y_pred = et.predict(X_test)
328+ print (
329+ " flamlized et accuracy" ,
330+ " =" ,
331+ 1 - sklearn_metric_loss_score(" accuracy" , y_pred, y_test),
332+ )
333+ print (et)
334+ ```
335+
336+ #### Sample output
337+
338+ ```
339+ load dataset from ./openml_ds1169.pkl
340+ Dataset name: airlines
341+ X_train.shape: (404537, 7), y_train.shape: (404537,);
342+ X_test.shape: (134846, 7), y_test.shape: (134846,)
343+ flamlized et accuracy = 0.6698
344+ ExtraTreesClassifier(max_features=0.7, min_samples_leaf=3, min_samples_split=5,
345+ n_estimators=500)
346+ ```
0 commit comments