Last active
November 22, 2020 08:51
-
-
Save ngmars/b0f639ca25bf93ee7a7812d9d2837833 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import joblib | |
import multiprocessing as mp | |
clf.fit(y_train, X_train) | |
weight = 'new_model.sav' | |
joblib.dump(clf, weight) | |
#define a function and pass your parameters | |
def predict(A): | |
y_test=A | |
y_test=np.asarray(y_test) | |
X_pred_prob = loaded_model.predict_proba(y_test) | |
prediction= loaded_binarizer.inverse_transform(X_pred_new) | |
print(prediction) | |
#make sure you return the vaule, this would help you create the API | |
return(A,prediction) | |
def mainPredict(Arr): | |
# if Arr =[1,2,3,4,5,6] and each value is an input parameter to predict | |
#initialize pool | |
pool = mp.Pool(mp.cpu_count()) | |
#map array elements to the predict function | |
result = pool.map(predict, Arr) | |
#close the pool | |
pool.close() | |
return(result) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment