Spaces:
Runtime error
Runtime error
File size: 1,472 Bytes
a43a1c2 8169128 a43a1c2 e32ef35 a43a1c2 3e9f349 a43a1c2 9b10745 eebeb36 a27924e 88eba6a eebeb36 a27924e eebeb36 7280d1e a43a1c2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import streamlit as st
import tensorflow as tf
import tensorflow_hub as hub
import numpy as np
new_model = tf.keras.models.load_model("best_model.h5",custom_objects={"KerasLayer": hub.KerasLayer}, compile=False)
def welcome():
return "Welcome to my app"
def main():
st.title("Financial News Sentiment Analysis App")
st.write(
"This app will tell you if mention news is Fake or Real by using Natural Language Processing")
html_temp = """
<div style="background-color:tomato;padding:10px">
<h2 style="color:white;text-align:center;">Financial News Sentiment Analysis </h2>
</div>
"""
st.markdown(html_temp, unsafe_allow_html=True)
text = st.text_area("Enter your Financial News")
if st.button("Predict"):
pred_prob = new_model.predict([text])
predict = tf.squeeze(tf.round(pred_prob)).numpy()
st.subheader("AI thinks that ...")
if predict == 0:
col1, col2 = st.columns(2)
col1.metric("Prediction", value="It's a Negative News.")
col2.metric("Confidence Level", value=f"{np.round(np.max(pred_prob) * 100)}%")
else:
col1, col2 = st.columns(2)
col1.metric("Prediction", value="It's a Positive News.")
col2.metric("Confidence Level", value=f"{np.round(np.max(pred_prob) * 100)}%")
if st.button("About"):
st.text("Built with Streamlit")
if __name__ == '__main__':
main()
|