wiqasali commited on
Commit
d274150
·
verified ·
1 Parent(s): 6dfbd02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -27
app.py CHANGED
@@ -1,31 +1,50 @@
 
1
  import streamlit as st
2
- import yt_dlp
3
-
4
- def download_video(url):
5
- try:
6
- ydl_opts = {
7
- 'format': 'best',
8
- 'outtmpl': 'downloads/%(title)s.%(ext)s',
9
- }
10
- with yt_dlp.YoutubeDL(ydl_opts) as ydl:
11
- info = ydl.extract_info(url, download=True)
12
- return info.get('title', 'Video')
13
- except Exception as e:
14
- return str(e)
15
-
16
- st.title("YouTube Video Downloader")
17
-
18
- url = st.text_input("Enter the YouTube URL")
19
-
20
- if st.button("Download"):
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
- st.error("Please provide a YouTube URL.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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