Spark MLLib - how to re-use TF-IDF model I am using spark ml IDF estimator/model (TF-IDF) to convert text features into vectors before passing it to the classification algorithm.
Here's the process:

Datasets: 

Full sample data (labeled) &lt;br&gt;
Training (labeled)&lt;br&gt;
Test (labeled)&lt;br&gt;
Unseen (non-labeled)&lt;br&gt;


This is my current workflow:

Fit IDF model (idf-1) on full Sample data&lt;br&gt;
Apply(Transform) idf-1 on full sample data&lt;br&gt;
Split data set into Training and Test data&lt;br&gt;
Fit ML model on Training data&lt;br&gt;
Apply(Transform) model on Test data&lt;br&gt;
Apply(Transform) idf-1 on Unseen data&lt;br&gt;
Apply(Transform) model on Unseen data&lt;br&gt;


I read somewhere that I should split my data into training and test BEFORE fitting IDF model; Fit IDF only on training data and then use the same transformer to transform training and test data. 

Why would you do that? What exactly do IDF learn during the fitting process that it can reuse to transform any new dataset. Perhaps, idea is to keep same value for |D| and DF|t, D| while use new TF|t, D| ?

Also, how often I will Fit (not transform) IDF model against new unseen data? let say my model is ready for prediction. I made n prediction using same IDF and Classifier model. After that I want to retrain model as I have new data now. Should I also retrain IDF then?
tf-idf will learn a vocabulary, idf, and some will also learn stop words (based on min_df, max_df, max_features). Read over sklearn's TfidfVectorizer and you can see the attributes that the fit method will set. 

When you expose a trained tf-idf to new data it will transform that data into a vector of the same size as your original data using the vocabulary to construct Term_Counts which are then converted into your tf vector. The value in this is that you can use another model to predict an outcome based on the tf_idf as each new document will have the same size tf_idf vector as the documents you used to train the model. Otherwise you couldn't use it to make a prediction! For example with a naive bayes classifying tfidf:

tfidf = TfidfVectorizer()
X = tfidf.fit_transform(X_train)
nb = MultinomialNB()
nb.fit(X, y_train)

# When you receive a new document
X = tfidf.transform(new_doc)
prediction = nb.predict_proba(X)


And I don't think you would want to refit the model. If you want some kind of continuous real-time update consider implementing a bayesian update