File size: 1,811 Bytes
4f642eb
9321404
 
 
41c16db
4f642eb
9321404
 
220ae8f
41c16db
9321404
5a057ad
 
 
 
9b047e4
 
 
 
 
41c16db
 
 
 
 
9321404
41c16db
 
9321404
 
5a057ad
9321404
 
 
 
 
 
24f5b17
9321404
 
 
ed53591
9321404
24f5b17
 
5a057ad
 
 
 
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
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')