When attempting to run the AutoML fit method with custom StratifiedKFold cross-validation, an error occurs in the FLAML library. The error message indicates that the StratifiedKFold.split() method is missing a required positional argument: 'y'.
Code:
from flaml import AutoML
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split, StratifiedKFold
# Load the dataset
data = load_breast_cancer()
X = data.data
y = data.target
# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42
)
# Initialize the AutoML object
automl = AutoML()
# Define custom cross-validation split
cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
# Define the settings for the AutoML run
settings = {
"time_budget": 60 * 60 * 8, # 8 hours
"metric": "accuracy",
"task": "classification",
"estimator_list": ["lgbm"], # LightGBM
"eval_method": "cv", # Cross-validation
"ensemble": True,
"n_splits": 5, # Number of cross-validation splits
"split_type": cv, # Custom split type
}
# Run the AutoML fit method
automl.fit(X_train, y_train, **settings)
When attempting to run the AutoML fit method with custom StratifiedKFold cross-validation, an error occurs in the FLAML library. The error message indicates that the
StratifiedKFold.split()
method is missing a required positional argument: 'y'.Code:
Error Message: