File size: 1,803 Bytes
21d6676
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4728924
21d6676
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
56
57
import streamlit as st
import pandas as pd
import plotly.express as px

# Function to load predictions
@st.cache_data
def load_predictions(filename):
    data = pd.read_csv(filename)
    data['Date'] = pd.to_datetime(data['Date']).dt.strftime('%Y-%m')
    return data

# Title and Introduction with icons
st.title('💹 2022 Receipt Count Predictions')
st.markdown("## Explore the Receipt Count Predictions for the year 2022 📈")

# Sidebar for model selection
st.sidebar.title("🔍 Model Selection")
model_option = st.sidebar.selectbox(
    'Choose a model:',
    ('LSTM', 'RNN', 'Prophet')
)

# Button to load predictions
if st.sidebar.button('Get Predictions'):
    filename_map = {'LSTM': 'results/LSTM_predictions-final.csv', 
                    'RNN': 'results/RNN_predictions-final.csv', 
                    'Prophet': 'results/Prophet_predictions.csv'}

    predictions = load_predictions(filename_map[model_option])

    # Display Data Table
    st.markdown("### Predicted Receipt Counts")
    st.dataframe(predictions)

    # Plotting Predictions and fixing the error
    st.markdown("### Interactive Prediction Graph")
    fig = px.line(predictions, x='Date', y='Prediction', 
                  title=f'Monthly Predicted Receipt Counts for 2022 ({model_option} Model)', 
                  markers=True)
    st.plotly_chart(fig, use_container_width=True)

    # Download links
    st.markdown('## Download Results')
    st.download_button(
        label="Download Data as CSV",
        data=predictions.to_csv(index=False).encode('utf-8'),
        file_name='predictions.csv',
        mime='text/csv',
    )

    st.download_button(
        label="Download Plot as Image",
        data=fig.to_image(format="png"),
        file_name='predictions_plot.png',
        mime='image/png',
    )