Spaces:
Sleeping
Sleeping
File size: 9,556 Bytes
02309fd |
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.ensemble import RandomForestClassifier
from prophet import Prophet
# Load dataset
@st.cache_data
def load_data(filename):
return pd.read_csv(filename)
# Main application
st.sidebar.title("AI-Powered Industrial Management")
page = st.sidebar.radio("Choose a page", ["Predictive Maintenance for Wind Turbines", "Intelligent Energy Management Systems"])
# Predictive Maintenance for Wind Turbines
if page == "Predictive Maintenance for Wind Turbines":
st.header("Predictive Maintenance for Wind Turbines")
# Load and display dataset
data = load_data('wind_turbine_data.csv')
st.write("### Dataset Preview:")
st.write(data.head())
# Dataset Meta Information
st.write("### Dataset Meta Information:")
st.write("""
- **Timestamp:** The time at which the data was recorded.
- **Turbine_ID:** Unique identifier for each wind turbine.
- **Wind_Speed (m/s):** The speed of the wind at the time of measurement.
- **Ambient_Temperature (°C):** The outside temperature where the turbine is located.
- **Power_Output (MW):** The power generated by the turbine at the time of measurement.
- **Blade_Vibration (mm/s):** The vibration level of the turbine blades, a critical indicator of potential mechanical issues.
- **Gearbox_Temperature (°C):** Temperature inside the turbine's gearbox.
- **Oil_Level (%):** The level of lubrication oil in the turbine.
- **Maintenance_History (0/1):** Whether the turbine underwent maintenance in the last 30 days (1) or not (0).
- **Component_Failure (0/1):** Whether a component failure occurred (1) or not. This is the target variable.
""")
# Data Exploration
st.write("### Data Exploration")
# Select Graph Type
graph_type = st.selectbox("Select a graph to visualize:",
["Wind Speed Distribution",
"Ambient Temperature vs. Power Output",
"Blade Vibration vs. Gearbox Temperature",
"Oil Level Distribution"])
# Plotting based on selection
if graph_type == "Wind Speed Distribution":
st.write("#### Wind Speed Distribution")
plt.figure(figsize=(10, 6))
plt.hist(data['Wind_Speed'], bins=20, color='skyblue', edgecolor='black')
plt.xlabel('Wind Speed (m/s)')
plt.ylabel('Frequency')
plt.title('Distribution of Wind Speed')
st.pyplot(plt)
st.write("This graph shows the distribution of wind speeds recorded in the dataset. "
"It helps in understanding the common wind speeds at which the turbines operate, "
"which can be crucial for assessing turbine performance and predicting failures.")
elif graph_type == "Ambient Temperature vs. Power Output":
st.write("#### Ambient Temperature vs. Power Output")
plt.figure(figsize=(10, 6))
plt.scatter(data['Ambient_Temperature'], data['Power_Output'], color='green', alpha=0.6)
plt.xlabel('Ambient Temperature (°C)')
plt.ylabel('Power Output (MW)')
plt.title('Ambient Temperature vs. Power Output')
st.pyplot(plt)
st.write("This scatter plot illustrates the relationship between ambient temperature and power output. "
"It shows how temperature variations can affect the power generated by the wind turbines, "
"which is important for understanding operational efficiency under different weather conditions.")
elif graph_type == "Blade Vibration vs. Gearbox Temperature":
st.write("#### Blade Vibration vs. Gearbox Temperature")
plt.figure(figsize=(10, 6))
plt.scatter(data['Blade_Vibration'], data['Gearbox_Temperature'], color='orange', alpha=0.6)
plt.xlabel('Blade Vibration (mm/s)')
plt.ylabel('Gearbox Temperature (°C)')
plt.title('Blade Vibration vs. Gearbox Temperature')
st.pyplot(plt)
st.write("This scatter plot shows the correlation between blade vibration and gearbox temperature. "
"High levels of blade vibration can indicate mechanical issues, and this plot helps in identifying "
"potential stress on the gearbox due to vibrations.")
elif graph_type == "Oil Level Distribution":
st.write("#### Oil Level Distribution")
plt.figure(figsize=(10, 6))
plt.hist(data['Oil_Level'], bins=20, color='purple', edgecolor='black')
plt.xlabel('Oil Level (%)')
plt.ylabel('Frequency')
plt.title('Distribution of Oil Level')
st.pyplot(plt)
st.write("This histogram displays the distribution of oil levels in the turbines. "
"Maintaining optimal oil levels is crucial for the smooth operation of turbine components. "
"This graph helps in understanding how often turbines operate with low or high oil levels, "
"which can impact their reliability and longevity.")
# Predictive Maintenance
st.write("### Predict Equipment Failure")
user_input = {
'Wind_Speed': st.number_input('Wind Speed (m/s)'),
'Ambient_Temperature': st.number_input('Ambient Temperature (°C)'),
'Power_Output': st.number_input('Power Output (MW)'),
'Blade_Vibration': st.number_input('Blade Vibration (mm/s)'),
'Gearbox_Temperature': st.number_input('Gearbox Temperature (°C)'),
'Oil_Level': st.number_input('Oil Level (%)'),
'Maintenance_History': st.selectbox('Maintenance History (0/1)', [0, 1])
}
input_df = pd.DataFrame([user_input])
# Load pre-trained model (assumed pre-trained, you should load it here)
model = RandomForestClassifier() # This is where you would load your trained model
model.fit(data.drop(columns=['Component_Failure', 'Timestamp', 'Turbine_ID']), data['Component_Failure']) # For demonstration only
prediction = model.predict(input_df)
st.write(f"Predicted Component Failure: {'Yes' if prediction[0] == 1 else 'No'}")
# Intelligent Energy Management Systems
elif page == "Intelligent Energy Management Systems":
st.header("Intelligent Energy Management Systems")
# Load the datasets
energy_df = load_data('energy_consumption.csv')
production_df = load_data('production_schedule.csv')
pricing_df = load_data('energy_pricing.csv')
# Function to display dataset metadata
def display_metadata(df, title):
st.subheader(f"{title} Metadata")
st.write(f"Number of records: {df.shape[0]}")
st.write(f"Number of columns: {df.shape[1]}")
st.write("Columns:")
for col in df.columns:
st.write(f"- **{col}**: {df[col].dtype}")
st.write("""
This app demonstrates AI-powered systems that can dynamically manage and allocate energy resources in industrial settings, optimizing energy consumption in real time.
""")
# Display dataset metadata information
st.write("### Dataset Metadata Information")
st.write("""
#### Energy Consumption Data:
This dataset records the energy consumption of different machines over time, along with associated parameters like temperature, humidity, and operational status.
""")
display_metadata(energy_df, "Energy Consumption")
st.write("""
#### Production Schedule Data:
This dataset contains the production schedules for different machines, including the start and end times of production, the type of product being produced, and the target output.
""")
display_metadata(production_df, "Production Schedule")
st.write("""
#### Energy Pricing Data:
This dataset provides the energy pricing information over time, including indicators for peak hours, which can influence energy consumption optimization strategies.
""")
display_metadata(pricing_df, "Energy Pricing")
# Visualization: Energy consumption over time for a selected machine
st.header("Energy Consumption Analysis by Machine")
selected_machine = st.selectbox("Select a Machine ID", energy_df['machine_id'].unique())
machine_energy_df = energy_df[energy_df['machine_id'] == selected_machine]
fig, ax = plt.subplots()
ax.plot(pd.to_datetime(machine_energy_df['timestamp']), machine_energy_df['energy_consumed_kWh'], label='Energy Consumption (kWh)', color='blue')
ax.set_xlabel('Timestamp')
ax.set_ylabel('Energy Consumed (kWh)')
ax.legend()
st.pyplot(fig)
st.write("""
This graph shows the energy consumption for the selected machine over time.
""")
# AI-Powered Forecasting
st.header("Energy Consumption Forecasting")
# Prepare the data for Prophet
forecast_data = machine_energy_df[['timestamp', 'energy_consumed_kWh']].rename(columns={'timestamp': 'ds', 'energy_consumed_kWh': 'y'})
# Initialize Prophet model
model = Prophet()
model.fit(forecast_data)
# Create future dataframe
future = model.make_future_dataframe(periods=48, freq='H') # Forecasting the next 48 hours
# Forecast
forecast = model.predict(future)
# Plot the forecast
st.subheader("Forecasting Results")
fig1 = model.plot(forecast)
st.pyplot(fig1)
fig2 = model.plot_components(forecast)
st.pyplot(fig2)
st.write("""
The above charts display the forecasted energy consumption for the selected machine over the next 48 hours, along with the trend and seasonality components.
""")
|