microsoft / FLAML

A fast library for AutoML and tuning. Join our Discord: https://discord.gg/Cppx2vSPVP.
https://microsoft.github.io/FLAML/
MIT License
3.87k stars 504 forks source link

TypeError: LogisticRegression.fit() got an unexpected keyword argument 'gpu_per_trial' #1047

Open azachar opened 1 year ago

azachar commented 1 year ago

Hello,

I'm experiencing an issue when trying to run AutoFLAML with the gpu_per_trial argument. Here is the setup that I'm using:

automl = AutoML()

automl_settings = {
   'time_budget': 10,
   'metric': 'accuracy',
   'task': 'classification',
   'estimator_list': 'auto',
   'n_jobs': -1,
   'use_ray': True,
   'n_concurrent_trials': 10,
   'gpu_per_trial': 0.1  
}

automl.fit( X_train=X, y_train=y, **automl_settings)

When I run AutoFLAML with this setup, I get the following error:

TypeError: LogisticRegression.fit() got an unexpected keyword argument 'gpu_per_trial'

From my understanding, 'gpu_per_trial' is supposed to be a parameter for the RayTune backend to handle distribution of GPU resources across the trials. However, it seems like this argument is being passed to the fit method of the models AutoFLAML is training, which is causing the error.

I'm currently using AutoFLAML version 1.2.3. Is this a known issue, or is there something I'm missing in my configuration? Any guidance on this would be appreciated.

Thank you!

Best regards, Andrej

sonichi commented 1 year ago

gpu_per_trial only works for xgboost and xgb_depth for 'classification' task. You can follow this example to specify fit_kwargs_by_estimator: https://microsoft.github.io/FLAML/docs/Use-Cases/Task-Oriented-AutoML#extra-fit-arguments

ronylpatil commented 5 months ago

Hi,

I am facing same issue with enable_categorical parameter of XGBoost Regressor but its showing error: fit() got an unexpected keyword argument 'enable_categorical'

from flaml import AutoML
from sklearn.datasets import fetch_california_housing

automl = AutoML()
automl_settings = {
    "time_budget": 50,  # in seconds
    "metric": "mse",
    "task": "regression",
    "estimator_list": ['xgboost'],
    "fit_kwargs_by_estimator": {"xgboost": {"enable_categorical": True}}
}

automl.fit(X_train = X, y_train = y, **automl_settings)

I trained the XGBoost model with same parameter but in Flaml I am facing issues, please have a look into it.

Thank You

Kind Regards, Ronil

sonichi commented 5 months ago

Could you share the code that works for xgboost? And the xgboost version in both cases?