Atchyuteswar's picture
Upload 5 files
61f1540 verified
Raw History Blame Contribute Delete
5.76 kB
import streamlit as st
import tensorflow as tf
from joblib import load
from xgboost import XGBClassifier
@st.cache_resource()
def load_model():
preprocessor = load("preprocess_pipeline.joblib")
xgb_model = XGBClassifier()
xgb_model.load_model("xgb_clf.json")
tf_model = tf.keras.models.load_model("lstm_model.keras", compile=False)
return preprocessor, xgb_model, tf_model
# Text Box Input
st.title("Fake News Detection")
st.subheader("Enter the news text below:")
news_text = st.text_area(
"News Text",
"""nestle to launch new nongmo products how shocked will monsanto be
thursday october 27 2016 by vicki batts tags gmos nestle monsanto
naturalnews one of the food industrys most prominent players recently
announced that they will be expanding their line of nongmo products due
to the everincreasing customer demand for clean food nestle may have wowed
consumers with their choice but it may make some waves with their good friend
monsanto the company is broadening its product offerings to give consumers more
options with no gmo ingredients and identifying these products with the sgsverified
no gmo ingredients claim the food giant stated on tuesdaynestle usa understands that
consumers are seeking choice and many prefer to select products with no gmo ingredients
they declaredof course this is not nestles first move towards gmofree products in april
nestle announced that they would be removing gmo ingredients from six of their topselling
ice cream products as well the company states it is trying to evolve along with consumer
demands it is great to see that companies are beginning to realize that consumers want options
no one wants to be forced to buy gmo productsit is easy to want to applaud nestle for their
decision to continue to expand their line of nongmo products however it is also clear that
this company is doing so out of their own financial interests – not because they care about what people
are eating organic gmofree foods are the newest trend and smart manufacturers are beginning to see that
they will not win anyone over by insisting that gm pesticideladen food products are safe if you cant beat
em join em is a philosophy nestle has clearly taken to heartnestle is not an angelic company even if they have
decided to start serving up gmofree options just three years ago they donated millions of dollars to prevent
and oppose gmo labeling in washington state along with monsanto and other biotech firms truth out reports that
on october 18 2013 the grocery manufacturers of america disclosed that several of their largest most powerful
players silently donated large sums of money to oppose initiative 522 this bill would have required grocery
items containing gmo ingredients to be labeled as such the group chose to voluntarily release the names of the
silent donors after washington state attorney general bob ferguson filed a lawsuit against their concealment of
corporate donorsnestle was among the top three highest contributors and donated a cool 15 million to keep gmo
ingredients under wraps and off product labels nestle also made a large donation to oppose similar legislation
in california the year before in 2012 the bill ultimately failed after big food and big biotech joined forces
and together raised a staggering 46 million to prevent its passing and were supposed to believe they carethe
controversial history of nestle doesnt end with their consistent financial support of gmo labeling opposition
efforts it is a corporation that is wrought with wrongdoings and corrupt practices look no further than their
outright theft of water in californiagiven that the coastal state is currently being plagued by a devastating
drought you might be shocked to learn that just last year nestle pumped a disturbing 36 million gallons of water
out of one of the states water sources known as strawberry creek peter gleick president of the pacific institute
and author of bottled and sold the story behind our obsession with bottled water estimates that nestle is making
millions of dollars in this waytheyre converting a public resource into private profit he told los angeles magazine
the most shocking thing is that their permit to pump water from the creek expired in 1988 the forest service has
allowed nestle to gouge the creek for water at will so long as they continue to pay a minuscule access fee while
bottled water accounts for only a small fraction of californias water use the overall environmental impact of what
their practices are doing to a droughtstricken state have yet to be examinednestle has been subject to countless
other controversies including human rights violations and has been host to many environmental and product safety
issuesto put it simply nestle may be trying to win over customers with their nongmo products but they dont deserve
to monsanto may be shocked but only because nestle is still one of their own sources""",
)
preprocessor, xgb_model, tf_model = load_model()
# Predict Button
if st.button("Predict"):
data = preprocessor.transform([news_text])
# XGBoost Model
xgb_pred = xgb_model.predict(data)
if xgb_pred[0] == 1:
st.write("XGBoost Model Prediction: Fake News")
else:
st.write("XGBoost Model Prediction: Real News")
# TensorFlow Model
tf_pred = tf_model.predict([news_text])
if tf_pred[0][0] > 0.5:
st.write("TensorFlow Model Prediction: Fake News")
else:
st.write("TensorFlow Model Prediction: Real News")