so normally we create a TfIdfVectorizer as
TfidfVectorizer(stop_words='english',sublinear_tf=True,use_idf=True)
what if the parameters were in a map? is there a way to dynamically set the parameters for the TfIdfVectorizer?
You could store your parameters in a dictionary and set them from there:
params = {'stop_words':'english','sublinear_tf':True,'use_idf'=True}
TfidfVectorizer(stop_words=params['stop_words'],sublinear_tf=params['sublinear_tf'],use_idf=params['use_idf']).
However Python also has a special syntax that allows you to pass paramaters in using a dict, which will achieve the same result as the above:
TfidfVectorizer(**params)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With