Spaces:
Running
Running
Commit
·
2ba7c2a
1
Parent(s):
c13890e
re-added app.py
Browse files
app.py
CHANGED
@@ -1,123 +1,102 @@
|
|
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 |
-
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
-
|
73 |
|
74 |
-
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
|
84 |
-
#
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
|
97 |
-
#
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
|
103 |
-
import streamlit as st
|
104 |
-
import pandas as pd
|
105 |
-
# Load Model
|
106 |
-
#model = pickle.load(open('logreg_model.pkl', 'rb'))
|
107 |
-
st.title('Iris Variety Prediction')
|
108 |
-
# Form
|
109 |
-
with st.form(key='form_parameters'):
|
110 |
-
sepal_length = st.slider('Sepal Length', 4.0, 8.0, 4.0)
|
111 |
-
sepal_width = st.slider('Sepal Width', 2.0, 4.5, 2.0)
|
112 |
-
petal_length = st.slider('Petal Length', 1.0, 7.0, 1.0)
|
113 |
-
petal_width = st.slider('Petal Width', 0.1, 2.5, 0.1)
|
114 |
-
st.markdown('---')
|
115 |
-
submitted = st.form_submit_button('Predict')
|
116 |
-
# Data Inference
|
117 |
-
data_inf = {
|
118 |
-
'sepal.length': sepal_length,
|
119 |
-
'sepal.width': sepal_width,
|
120 |
-
'petal.length': petal_length,
|
121 |
-
'petal.width': petal_width
|
122 |
-
}
|
123 |
-
data_inf = pd.DataFrame([data_inf])
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import json
|
3 |
+
import pandas as pd
|
4 |
+
import plotly.express as px
|
5 |
+
import requests
|
6 |
+
from datetime import datetime
|
7 |
+
import plotly.graph_objects as go
|
8 |
+
import os
|
9 |
+
import logging
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
# Configure the main page
|
15 |
+
st.set_page_config(
|
16 |
+
page_title="Energy Data Analysis Dashboard",
|
17 |
+
page_icon="⚡",
|
18 |
+
layout="wide",
|
19 |
+
initial_sidebar_state="expanded"
|
20 |
+
)
|
21 |
+
|
22 |
+
#DEFAULT_TOKEN = os.getenv('NILM_API_TOKEN', '')
|
23 |
+
DEFAULT_TOKEN = 'p2s8X9qL4zF7vN3mK6tR1bY5cA0wE3hJ'
|
24 |
+
print(DEFAULT_TOKEN)
|
25 |
+
logger = logging.getLogger("Data cellar demo")
|
26 |
+
|
27 |
+
logger.info(f"token : {DEFAULT_TOKEN}")
|
28 |
+
|
29 |
+
# Initialize session state variables
|
30 |
+
if 'api_token' not in st.session_state:
|
31 |
+
st.session_state.api_token = DEFAULT_TOKEN
|
32 |
+
if 'current_file' not in st.session_state:
|
33 |
+
st.session_state.current_file = None
|
34 |
+
if 'json_data' not in st.session_state:
|
35 |
+
st.session_state.json_data = None
|
36 |
+
if 'api_response' not in st.session_state:
|
37 |
+
st.session_state.api_response = None
|
38 |
+
|
39 |
+
# Sidebar configuration
|
40 |
+
with st.sidebar:
|
41 |
+
st.markdown("## API Configuration")
|
42 |
+
api_token = st.text_input("API Token", value=st.session_state.api_token, type="password")
|
43 |
+
if api_token:
|
44 |
+
st.session_state.api_token = api_token
|
45 |
|
46 |
+
st.markdown("""
|
47 |
+
## About
|
48 |
+
This dashboard provides analysis of energy data through various services
|
49 |
+
including NILM analysis, consumption and production forecasting.
|
50 |
+
""")
|
51 |
|
52 |
+
# Main page content
|
53 |
+
st.title("Energy Data Analysis Dashboard")
|
54 |
|
55 |
+
# Welcome message and service descriptions
|
56 |
+
st.markdown("""
|
57 |
+
Welcome to the Energy Data Analysis Dashboard! This platform provides comprehensive tools for analyzing energy consumption and production data.
|
58 |
|
59 |
+
### Available Services
|
60 |
|
61 |
+
You can access the following services through the navigation menu on the left:
|
62 |
|
63 |
+
#### 1. Energy Consumption Forecasting
|
64 |
+
- **Short Term**: Predict energy consumption patterns in the near future
|
65 |
+
- **Long Term**: Generate long-range consumption forecasts
|
66 |
|
67 |
+
#### 2. Energy Production Analysis
|
68 |
+
- **Short Term Production**: Forecast PV panel energy production
|
69 |
+
- **NILM Analysis**: Non-intrusive load monitoring for detailed consumption breakdown
|
70 |
|
71 |
+
#### 3. Advanced Analytics
|
72 |
+
- **Anomaly Detection**: Identify unusual patterns in energy consumption
|
73 |
|
74 |
+
### Getting Started
|
75 |
|
76 |
+
1. Select a service from the navigation menu on the left
|
77 |
+
2. Upload your energy data file in JSON format
|
78 |
+
3. Configure your API token if needed
|
79 |
+
4. Run the analysis and explore the results
|
80 |
|
81 |
+
Each service page provides specific visualizations and analytics tailored to your needs.
|
82 |
+
""")
|
83 |
|
84 |
+
# Add version info and additional resources in an expander
|
85 |
+
with st.expander("Additional Information"):
|
86 |
+
st.markdown("""
|
87 |
+
### Usage Tips
|
88 |
+
- Ensure your data is in the correct JSON format
|
89 |
+
- Keep your API token secure
|
90 |
+
- Use the visualization tools to explore your data
|
91 |
+
- Export results for further analysis
|
92 |
|
93 |
+
### Support
|
94 |
+
For technical support or questions about the services, please contact your system administrator.
|
95 |
+
""")
|
96 |
|
97 |
+
# Footer
|
98 |
+
st.markdown("""
|
99 |
+
---
|
100 |
+
Made with ❤️ by tLINKS Foundation
|
101 |
+
""")
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|