ryanrahmadifa
Added more features.
220ae8f
raw
history blame
1.81 kB
import streamlit as st
import pandas as pd
from modules.data_preparation import prepare_df, plot_3dgraph
import numpy as np
from datetime import datetime
st.title('Sentiment Analysis for Price Trend Prediction')
st.header(f'Data based on News Data')
st.subheader(f'{datetime.now()}')
news_categories = st.multiselect("Select desired Market Movers categories",
["Macroeconomic & Geopolitics", "Crude Oil", "Light Ends", "Middle Distillates", "Heavy Distillates", "Other"],
["Macroeconomic & Geopolitics", "Crude Oil"])
date_filter = st.slider(
"Date Filter",
value=(datetime(2024, 8, 4), datetime(2024,8,9)),
format="MM/DD/YY",
)
#latest_news = prepare_df(pd.read_csv('data/results_platts_09082024_clean.csv'), news_categories)
#top_news = prepare_df(pd.read_csv('data/topresults_platts_09082024_clean.csv'), news_categories)
#df_news = pd.concat([latest_news, top_news], ignore_index=True).drop_duplicates(['headline'])
latest_news = prepare_df(pd.read_excel('evaluation.xlsx'), news_categories, date_filter)
df_news = pd.concat([latest_news], ignore_index=True).drop_duplicates(['headline'])
df_mean = pd.DataFrame({
'headline' : ['MEAN OF SELECTED NEWS'],
'negative_score' : [df_news['negative_score'].mean()],
'neutral_score' : [df_news['neutral_score'].mean()],
'positive_score' : [df_news['positive_score'].mean()],
'topic_verification' : ['']
})
df_news_final = pd.concat([df_news, df_mean])
df_news_final.index = np.arange(1, len(df_news_final) + 1)
st.dataframe(df_news_final.drop(columns=['body', 'headline']).iloc[:, : 7])
st.markdown('---')
try:
st.plotly_chart(plot_3dgraph(df_news_final), use_container_width=True)
except:
st.subheader('Select news categories to plot 3D graph')