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

Where can I get the corresponding model for each cross validation #1269

Open
huangssssir opened this issue Jan 22, 2024 · 1 comment
Open

Comments

@huangssssir
Copy link

Hello. I need to obtain the training and test data corresponding to each grouping in cross validation, as well as the corresponding trained model, for subsequent analysis. How can I get this?

@Programmer-RD-AI
Copy link

kf = KFold(n_splits=5, shuffle=True, random_state=42)
model = RandomForestClassifier()
for fold, (train_index, test_index) in enumerate(kf.split(X)):
    model.fit(X_train, y_train)

With the use of a code snippet similar to the above you can use resolve your issue...
Let me know if there is an issue :)
Best regards,
Ranuga

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

2 participants