Sam
Sam

Reputation: 641

Combination of all parameters for grid search

I'm training a FastText word-representation model, and I'm performing a grid search over a range of multiple parameters. Below is multiple parameter lists:

wordNgrams = [2, 3, 4, 5]
lr = [10e-2, 10e-3, 10e-4, 10e-5, 10e-6]
dim = [200, 250, 300]
ws = [5, 6, 8, 10]

I'd like to try every possible combination for the above lists together and pass them as parameters to train my model. I don't know how to implement a python function to do that and was hoping for some help. Please help.

Upvotes: 2

Views: 2317

Answers (2)

Xichan
Xichan

Reputation: 95

You could also use ParameterGrid from sklearn.model_selection. Explained better in answer to a similar question here.

Upvotes: 0

U13-Forward
U13-Forward

Reputation: 71580

IIUC use itertools:

from itertools import product
print(product(wordNgrams, lr, dim, ws,repeat=4))

Upvotes: 3

Related Questions