Skip to content

Instantly share code, notes, and snippets.

@lakshay-arora
Last active April 28, 2020 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lakshay-arora/9159c58f1f1a36425221dee08aecdfe2 to your computer and use it in GitHub Desktop.
Save lakshay-arora/9159c58f1f1a36425221dee08aecdfe2 to your computer and use it in GitHub Desktop.
# importing the required libraries
from flask import Flask, render_template, request, redirect, url_for
from joblib import load
from get_tweets import get_related_tweets
# load the pipeline object
pipeline = load("text_classification.joblib")
# function to get results for a particular text query
def requestResults(name):
# get the tweets text
tweets = get_related_tweets(name)
# get the prediction
tweets['prediction'] = pipeline.predict(tweets['tweet_text'])
# get the value counts of different labels predicted
data = str(tweets.prediction.value_counts()) + '\n\n'
return data + str(tweets)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment