Unable to save the TF-IDF vectorizer
The issue is due to your lamda function with the tokenizer key word argument.

&gt;&gt;&gt; from sklearn.feature_extraction.text import TfidfVectorizer
&gt;&gt;&gt; from joblib import dump
&gt;&gt;&gt; t = TfidfVectorizer()
&gt;&gt;&gt; dump(t, 'tfidf.pkl')
['tfidf.pkl']


No issues. Now let's pass a lambda function to tokenizer

&gt;&gt;&gt; t = TfidfVectorizer(tokenizer=lambda x: x.split())
&gt;&gt;&gt; dump(t, 'tfidf.pkl')


Which throws the following error:


  _pickle.PicklingError: Can't pickle  at 0x100e18b90>: it's not found as main.


To get around this, create a function to split the text:

&gt;&gt;&gt; def text_splitter(text):
...     return text.split()


Try dumping again:

&gt;&gt;&gt; t = TfidfVectorizer(tokenizer=text_splitter)
&gt;&gt;&gt; dump(t, 'tfidf.pkl')
['tfidf.pkl']


Now you can you save the vectorizer.