microsoft / FLAML

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

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

Open huangssssir opened 5 months ago

huangssssir commented 5 months ago

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 commented 1 month ago
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