Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. # Load all classifiers from the pickled files
  2.  
  3. # function to load models given filepath
  4. def load_model(file_path):
  5. classifier_f = open(file_path, "rb")
  6. classifier = pickle.load(classifier_f)
  7. classifier_f.close()
  8. return classifier
  9.  
  10.  
  11. # Original Naive Bayes Classifier
  12. ONB_Clf = load_model('pickled_algos/ONB_clf.pickle')
  13.  
  14. # Multinomial Naive Bayes Classifier
  15. MNB_Clf = load_model('pickled_algos/MNB_clf.pickle')
  16.  
  17.  
  18. # Bernoulli Naive Bayes Classifier
  19. BNB_Clf = load_model('pickled_algos/BNB_clf.pickle')
  20.  
  21. # Logistic Regression Classifier
  22. LogReg_Clf = load_model('pickled_algos/LogReg_clf.pickle')
  23.  
  24. # Stochastic Gradient Descent Classifier
  25. SGD_Clf = load_model('pickled_algos/SGD_clf.pickle')
  26.  
  27. **************************************************************
  28.  
  29. # Initializing the ensemble classifier
  30. ensemble_clf = EnsembleClassifier(ONB_Clf, MNB_Clf, BNB_Clf, LogReg_Clf, SGD_Clf)
  31.  
  32. # List of only feature dictionary from the featureset list of tuples
  33. feature_list = [f[0] for f in testing_set]
  34.  
  35. # Looping over each to classify each review
  36. ensemble_preds = [ensemble_clf.classify(features) for features in feature_list]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement