Skip to content

Instantly share code, notes, and snippets.

@pemagrg1
Created September 4, 2019 11:39
Show Gist options
  • Select an option

  • Save pemagrg1/974fa10137212022321b6b79a22316a7 to your computer and use it in GitHub Desktop.

Select an option

Save pemagrg1/974fa10137212022321b6b79a22316a7 to your computer and use it in GitHub Desktop.

Revisions

  1. pemagrg1 created this gist Sep 4, 2019.
    10 changes: 10 additions & 0 deletions load-sklearn-pickle-and-predict.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    import pickle

    Project_path = "<path to project>"
    model_path = Project_path + "/08. Multi-class_text_classification/models/model.pickle"
    vectorizer_path = Project_path + "/08. Multi-class_text_classification/models/vectorizer.pickle"

    vectorizer = pickle.load(open(vectorizer_path,'rb'))
    model = pickle.load(open(model_path,'rb'))
    pred = model.predict(vectorizer.transform(["i have got a new phone. its from Apple.. and i love it!"]))[0]
    print ("predicted class:", pred)