Issue
I have a binary time series classification problem.
Since it is a time series, I can't just train_test_split
my data. So, I used the object tscv = TimeSeriesSplit()
from this link, and got something like this:
I can see from GridSearchCV and cross_val_score that i can pass as parameter my split strategy cv = tscv
. But my question is, whats the difference between GridSearchCV
and coss_val_score
? Using one of them is enough to train/test my model? or should i use both? First the GridSearchCV
to get the best hyperparamaters and then the cross_val_score
?
Solution
Grid search is a method to evaluate models by using different hyperparameter settings (the values of which you define in advance). Your GridSearch
can use cross validation (hence, GridSearchCV
exists) in order to deliver a final score for the the different parameter settings of your model. After the training and the evaluation (after the grid search has finished), you can take a look at the parameters with which your model performed best (by taking a look at the attribute best_params_dict
).So, Grid search is basically a brute forcing strategy in which you run the model with all possible hyperparameter combinations.
With coss_val_score
you don't perform the grid search (you don't use the strategy mentioned above with all predefined params), but you get the score after the cross-validation.
I hope it is now clear.
Answered By - t_e_o
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.