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
Save model/ model parameters after cross-validation #603
Comments
When using Tip: If you're annoyed by the print log from skorch during |
Shouldn't |
Well, the model hyperparameters stay the same of course, but the model itself is trained 10 times (i.e. the weights and biases of the neural net are reset and learned from scratch). |
So, basically, if I lean a model using cross-validation, there is no way for me to store the model i.e. no way to test the model's performance on completely new and unseen data? |
You can use cross_validate with |
Cool, didn't know about that option. Of course, you'd get 10 models back, still not sure what you would do with those. |
I want to use the best performing model out of those 10 models on unseen test data. I want to use cross-validation because my data set is not balanced, not to find the best set of hyper-parameters. So, without a model, there's no way for me to test on unseen data. |
You could also consider the Let me try to understand your problem: You use I think this approach your approach is a bit misguided. Since the 10 models are basically the same, there is really no point in choosing one of the 10 to work on your test data. In fact, I'm pretty certain that if you just train the model on the whole You say that you do this because your data is unbalanced. I assume what you mean is that your labels are unbalanced. E.g. you work with classification and one class is much more predominant than the other. There are a few ways to deal with unbalanced datasets, but the suggestion you made doesn't really solve the problem. You should think about other ideas like up- or downsampling your data (see e.g. here) or using different The main reason why you would need many folds for cross validation when working with unbalanced datasets is because you will encounter more variance in your validation scores. Using more folds gives you more confidence in how well the model would really generalize to unseen data. By itself, using many folds will not lead to a better model. I hope this clarifies some things for you. All of this is unrelated to skorch, it's more general machine learning/statistics question. You should be able to find more resources on this online. |
Thanks a lot @BenjaminBossan for your valuable suggestions. I have decided to follow two approaches, in the first approach, I will use Sklearn's cross_val_predict to get predictions over the whole |
Can you specify: Is your |
This is what I am doing right now,
|
If your |
@rudra0713 any updates or is the issue solved? |
Yes, this is resolved.
…On Mon, Apr 13, 2020 at 7:01 AM Benjamin Bossan ***@***.***> wrote:
@rudra0713 <https://github.com/rudra0713> any updates or is the issue
solved?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#603 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGH7XI5RGPDJEBJHNL5SRF3RMMLMBANCNFSM4LA3JZBQ>
.
--
Rudra Ranajee Saha
Graduate Research Assistant
University of British Columbia
|
Hi @BenjaminBossan , It's possible to save the 10 models (considering CV=10) using cross_val_score? I would like to create an ensemble of those models to apply on testset (e.g. get a majority vote on a classification problem). Is it possible to achieve this using Skorch? Cheers, |
Is this not covered by Thomas's response? |
You are right, sorry about that. Thank you again and sorry for the repeated question. Cheers, |
@Hguimaraes No worries, good luck with your models. |
Hi,
I am using Skorch and Sklearn with PyTorch for cross-validation. This is my code right now,
`
train_data_skorch = SliceDict(**train_data)
`
How can I save the model after cross-validation is done?
The text was updated successfully, but these errors were encountered: