File size: 2,154 Bytes
964e116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83c588b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
964e116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
58
59
60
61
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2024-07-19 20:27:12 Friday

@author: Nikhil Kapila
"""

import plotly.express as px
import pandas as pd

def standard_plotter(timestamp, true, predicted):
    return standard_plotly_maker(pd.DataFrame({
        'Date': timestamp,
        'Actual Values': true.flatten(),
        'Predicted Values': predicted.flatten()
    }))

def upgrade_plotter(hourly_data, df):
    # min_length = min(len(df.index), len(df.values.flatten()), len(hourly_data.values.flatten()))
    plot_data = pd.DataFrame({
        'Time': df.index,
        'Upgrade': df.values.flatten(),
        'Input': hourly_data.values.flatten()
    })

    fig = px.line(plot_data, x='Time', y=['Upgrade', 'Input'], labels={
        'value': 'Electricity Usage',
        'Time': 'Date and Time'
    }, title='Comparison of Electricity Usage')
    fig.data[1].opacity = 0.5
    fig.update_traces(mode='lines')
    return fig

def lookback_plotter(hourly_data, predicted):
    df = pd.concat([pd.DataFrame({'Time': hourly_data.index, 'Values': hourly_data.values.flatten(), 'Type': 'Original Data'}),
        pd.DataFrame({'Time': predicted.index, 'Values': predicted.values.flatten(), 'Type': 'Prediction'})])

    fig = px.line(df, x='Time', y='Values', color='Type', line_dash='Type',
                  labels={
                      'Values': 'Values',
                      'Time': 'Time',
                      'Type': 'Series Type'
                  },
                  title='Forecasted Predictions')

    # fig.update_xaxes(range=[hourly_data.index[-100], predicted.index[-1]])
    fig.update_xaxes(range=[hourly_data.index[-10], predicted.index[-2]])
    return fig

def standard_plotly_maker(df):
    fig = px.line(df, x='Date', y=['Actual Values', 'Predicted Values'],
                  labels={'value': 'Values', 'variable': 'Series'},
                  title='Actual vs Predicted Values')

    fig.update_traces(mode='lines', line=dict(dash='solid', width=2),
        selector=dict(name='Actual Values'))

    fig.update_traces(line=dict(dash='dash', width=2),selector=dict(name='Predicted Values'),)

    return fig