Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,50 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
-
import
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
if url:
|
22 |
-
with st.spinner("Downloading..."):
|
23 |
-
video_title = download_video(url)
|
24 |
-
if "https://" in url:
|
25 |
-
st.success(f"Downloaded: {video_title}")
|
26 |
-
else:
|
27 |
-
st.error("Invalid URL. Please enter a valid YouTube link.")
|
28 |
else:
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
|
|
31 |
|
|
|
1 |
+
|
2 |
import streamlit as st
|
3 |
+
import numpy as np
|
4 |
+
from sklearn.linear_model import LinearRegression
|
5 |
+
import pandas as pd
|
6 |
+
|
7 |
+
# Create the Streamlit app
|
8 |
+
st.title("Transformer Tap Changer Optimization App")
|
9 |
+
|
10 |
+
# Input fields for voltage and load
|
11 |
+
voltage_in = st.number_input("Enter the Input Voltage (kV)", min_value=90, max_value=150, value=115)
|
12 |
+
voltage_out = st.number_input("Enter the Output Voltage (kV)", min_value=80, max_value=130, value=100)
|
13 |
+
load = st.number_input("Enter the Current Load (MW)", min_value=50, max_value=500, value=250)
|
14 |
+
|
15 |
+
# Simple logic to determine the tap position based on voltage_out
|
16 |
+
def optimize_tap_change(voltage_in, voltage_out, load):
|
17 |
+
# Example logic to decide when to change tap position
|
18 |
+
if voltage_out < 95:
|
19 |
+
return "Tap 1 (Increase voltage)"
|
20 |
+
elif voltage_out > 105:
|
21 |
+
return "Tap 5 (Decrease voltage)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
else:
|
23 |
+
return "Tap 3 (Optimal position)"
|
24 |
+
|
25 |
+
# Display the recommended tap position
|
26 |
+
recommended_tap = optimize_tap_change(voltage_in, voltage_out, load)
|
27 |
+
|
28 |
+
st.write(f"**Recommended Tap Position**: {recommended_tap}")
|
29 |
+
|
30 |
+
# Create a simple dataset for machine learning model training
|
31 |
+
# Example data (features: voltage_in, load, previous_tap_change)
|
32 |
+
data = {
|
33 |
+
'voltage_in': [110, 115, 120, 125],
|
34 |
+
'load': [250, 300, 350, 400],
|
35 |
+
'tap_position': [3, 4, 2, 5] # Target variable: tap position
|
36 |
+
}
|
37 |
+
df = pd.DataFrame(data)
|
38 |
+
|
39 |
+
X = df[['voltage_in', 'load']] # Features
|
40 |
+
y = df['tap_position'] # Target variable
|
41 |
+
|
42 |
+
# Train the Linear Regression model
|
43 |
+
model = LinearRegression()
|
44 |
+
model.fit(X, y)
|
45 |
+
|
46 |
+
# Predict optimal tap position based on current input
|
47 |
+
predicted_tap = model.predict([[voltage_in, load]])
|
48 |
|
49 |
+
st.write(f"**Predicted Tap Position using Machine Learning**: Tap {int(predicted_tap[0])}")
|
50 |
|