StefanoBergia's picture
test_interface
5dc2797
raw
history blame
4.04 kB
# 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))