I have created an NLP model and saved the vectorizer and model in pickle file. I am using these pickle file for predicting the new data. Loading pickle takes around 10 minutes. I want to keep the pickle file loaded in memory and run the prediction when I get the input.
I have a file prediction.py
from sklearn.externals import joblib
count_vectorizer = joblib.load("C:/Count_Vectorizer.pkl")
count_classifier = joblib.load("C:/Count_Classifier.pkl")
X=sys.argv[1]
X_count = count_vectorizer.transform(X)
prediction = count_classifier.predict(X_count )
print(X,prediction)
I am running the python file with input string as an argument.
$ python prediction.py "Hello World"
IN this pickle file is loaded every time I am running the script. Is there anyway to make a program such that the pickle file is already loaded in memory and we run the prediction file and get the result?