File size: 4,044 Bytes
5dc2797
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
866cee0
 
5dc2797
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# import streamlit as st
# import json
# import pandas as pd
# import plotly.express as px
# import requests
# from datetime import datetime
# import plotly.graph_objects as go
# import os
# import logging




# # Configure the main page
# st.set_page_config(
#     page_title="Energy Data Analysis Dashboard",
#     page_icon="⚡",
#     layout="wide",
#     initial_sidebar_state="expanded"
# )

# #DEFAULT_TOKEN = os.getenv('NILM_API_TOKEN', '')
# DEFAULT_TOKEN = 'p2s8X9qL4zF7vN3mK6tR1bY5cA0wE3hJ'
# print(DEFAULT_TOKEN)
# logger = logging.getLogger("Data cellar demo")

# logger.info(f"token : {DEFAULT_TOKEN}")

# # Initialize session state variables
# if 'api_token' not in st.session_state:
#     st.session_state.api_token = DEFAULT_TOKEN
# if 'current_file' not in st.session_state:
#     st.session_state.current_file = None
# if 'json_data' not in st.session_state:
#     st.session_state.json_data = None
# if 'api_response' not in st.session_state:
#     st.session_state.api_response = None

# # Sidebar configuration
# with st.sidebar:
#     st.markdown("## API Configuration")
#     api_token = st.text_input("API Token", value=st.session_state.api_token, type="password")
#     if api_token:
#         st.session_state.api_token = api_token
    
#     st.markdown("""
#     ## About
#     This dashboard provides analysis of energy data through various services 
#     including NILM analysis, consumption and production forecasting.
#     """)

# # Main page content
# st.title("Energy Data Analysis Dashboard")

# # Welcome message and service descriptions
# st.markdown("""
# Welcome to the Energy Data Analysis Dashboard! This platform provides comprehensive tools for analyzing energy consumption and production data.

# ### Available Services

# You can access the following services through the navigation menu on the left:

# #### 1. Energy Consumption Forecasting
# - **Short Term**: Predict energy consumption patterns in the near future
# - **Long Term**: Generate long-range consumption forecasts

# #### 2. Energy Production Analysis
# - **Short Term Production**: Forecast PV panel energy production
# - **NILM Analysis**: Non-intrusive load monitoring for detailed consumption breakdown

# #### 3. Advanced Analytics
# - **Anomaly Detection**: Identify unusual patterns in energy consumption

# ### Getting Started

# 1. Select a service from the navigation menu on the left
# 2. Upload your energy data file in JSON format
# 3. Configure your API token if needed
# 4. Run the analysis and explore the results

# Each service page provides specific visualizations and analytics tailored to your needs.
# """)

# # Add version info and additional resources in an expander
# with st.expander("Additional Information"):
#     st.markdown("""
#     ### Usage Tips
#     - Ensure your data is in the correct JSON format
#     - Keep your API token secure
#     - Use the visualization tools to explore your data
#     - Export results for further analysis

#     ### Support
#     For technical support or questions about the services, please contact your system administrator.
#     """)

# # Footer
# st.markdown("""
# ---
# Made with ❤️ by tLINKS Foundation
# """)

import streamlit as st
import pandas as pd
import pickle
# Load Model
model = pickle.load(open('logreg_model.pkl', 'rb'))
st.title('Iris Variety Prediction')
# Form
with st.form(key='form_parameters'):
   sepal_length = st.slider('Sepal Length', 4.0, 8.0, 4.0)
   sepal_width = st.slider('Sepal Width', 2.0, 4.5, 2.0)
   petal_length = st.slider('Petal Length', 1.0, 7.0, 1.0)
   petal_width = st.slider('Petal Width', 0.1, 2.5, 0.1)
   st.markdown('---')
   submitted = st.form_submit_button('Predict')
# Data Inference
data_inf = {
   'sepal.length': sepal_length,
   'sepal.width': sepal_width,
   'petal.length': petal_length,
   'petal.width': petal_width
}
data_inf = pd.DataFrame([data_inf])
if submitted:
   # Predict using Logistic Regression
   y_pred_inf = model.predict(data_inf)
   st.write('## Iris Variety = '+ str(y_pred_inf))