Spaces:
Runtime error
Runtime error
ameya123ch
commited on
Commit
•
a43a1c2
1
Parent(s):
256034f
Upload 2 files
Browse files- app.py +52 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import tensorflow as tf
|
3 |
+
import tensorflow_hub as hub
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
new_model = tf.keras.models.load_model("best_model.h5",custom_objects={"KerasLayer": hub.KerasLayer})
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
def welcome():
|
15 |
+
return "Welcome to my app"
|
16 |
+
|
17 |
+
|
18 |
+
def main():
|
19 |
+
st.title("Financial News Sentiment Analysis App")
|
20 |
+
st.write(
|
21 |
+
"This app will tell you if mention news is Fake or Real by using Natural Language Processing")
|
22 |
+
html_temp = """
|
23 |
+
<div style="background-color:tomato;padding:10px">
|
24 |
+
<h2 style="color:white;text-align:center;">Financial News Sentiment Analysis </h2>
|
25 |
+
</div>
|
26 |
+
"""
|
27 |
+
st.markdown(html_temp, unsafe_allow_html=True)
|
28 |
+
|
29 |
+
text = st.text_input("Enter your Financial News")
|
30 |
+
|
31 |
+
|
32 |
+
if st.button("Predict"):
|
33 |
+
pred_prob = new_model.predict([text])
|
34 |
+
predict = tf.squeeze(tf.round(pred_prob)).numpy()
|
35 |
+
st.subheader("AI thinks that ...")
|
36 |
+
|
37 |
+
if predict > 0:
|
38 |
+
|
39 |
+
st.success(
|
40 |
+
f"It's a Positive News.You can make your investment decision accordingly. Confidence Level is {tf.round(pred_prob, 3)*100}%",icon="✅")
|
41 |
+
else:
|
42 |
+
st.warning(
|
43 |
+
f"It's a Negative News. Think twice before you take any investment decision. Confidence Level is {tf.round(100 - pred_prob, 3)*100}%", icon="⚠️")
|
44 |
+
|
45 |
+
if st.button("About"):
|
46 |
+
|
47 |
+
st.text("Built with Streamlit")
|
48 |
+
|
49 |
+
|
50 |
+
if __name__ == '__main__':
|
51 |
+
main()
|
52 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit==1.15.1
|
2 |
+
tensorflow_cpu==2.8.0
|
3 |
+
tensorflow_hub==0.12.0
|
4 |
+
|