Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: StratifiedKFold.split() missing 1 required positional argument: 'y' #1303

Open
Programmer-RD-AI opened this issue May 21, 2024 · 0 comments

Comments

@Programmer-RD-AI
Copy link
Contributor

Programmer-RD-AI commented May 21, 2024

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)

Error Message:

TypeError: StratifiedKFold.split() missing 1 required positional argument: 'y'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant