Skip to content

Instantly share code, notes, and snippets.

Last active Apr 28, 2020
What would you like to do?
# 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