Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,14 +22,11 @@ st.sidebar.header("Input Parameters")
|
|
| 22 |
budget = st.sidebar.number_input("Total Budget (in $1000s):", min_value=10, max_value=1000, step=10)
|
| 23 |
priority_area = st.sidebar.selectbox("Priority Area:", ["Rural", "Urban", "Suburban"])
|
| 24 |
signal_threshold = st.sidebar.slider("Signal Strength Threshold (dBm):", min_value=-120, max_value=-30, value=-80)
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# Display Dataset Options
|
| 27 |
-
data_to_view = st.sidebar.selectbox("Select Dataset to View:", ["Network Insights"])
|
| 28 |
-
|
| 29 |
-
# Display Selected Dataset
|
| 30 |
-
if data_to_view == "Network Insights":
|
| 31 |
-
st.subheader("Network Insights Dataset")
|
| 32 |
-
st.dataframe(network_insights)
|
| 33 |
|
| 34 |
# Terrain and Connectivity Analysis Section
|
| 35 |
st.header("Terrain and Connectivity Analysis")
|
|
@@ -42,6 +39,7 @@ def generate_terrain_data():
|
|
| 42 |
"Terrain Difficulty (0-10)": np.random.randint(1, 10, size=10),
|
| 43 |
"Signal Strength (dBm)": np.random.randint(-120, -30, size=10),
|
| 44 |
"Cost ($1000s)": np.random.randint(50, 200, size=10),
|
|
|
|
| 45 |
}
|
| 46 |
return pd.DataFrame(data)
|
| 47 |
|
|
@@ -49,12 +47,25 @@ terrain_data = generate_terrain_data()
|
|
| 49 |
|
| 50 |
# Filter Data Based on User Inputs
|
| 51 |
filtered_data = terrain_data[
|
| 52 |
-
(terrain_data["Signal Strength (dBm)"] >= signal_threshold) &
|
|
|
|
|
|
|
| 53 |
]
|
| 54 |
|
| 55 |
-
#
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
# Visualization
|
| 60 |
fig = px.scatter(
|
|
@@ -77,8 +88,8 @@ st.header("Deployment Recommendations")
|
|
| 77 |
def recommend_deployment(data):
|
| 78 |
if data.empty:
|
| 79 |
return "No viable deployment regions within the specified parameters."
|
| 80 |
-
best_region = data.loc[data["
|
| 81 |
-
return f"Recommended Region: {best_region['Region']} with Signal Strength: {best_region['Signal Strength (dBm)']} dBm and Estimated Cost: ${best_region['Cost ($1000s)']}k"
|
| 82 |
|
| 83 |
recommendation = recommend_deployment(filtered_data)
|
| 84 |
st.subheader(recommendation)
|
|
|
|
| 22 |
budget = st.sidebar.number_input("Total Budget (in $1000s):", min_value=10, max_value=1000, step=10)
|
| 23 |
priority_area = st.sidebar.selectbox("Priority Area:", ["Rural", "Urban", "Suburban"])
|
| 24 |
signal_threshold = st.sidebar.slider("Signal Strength Threshold (dBm):", min_value=-120, max_value=-30, value=-80)
|
| 25 |
+
terrain_weight = st.sidebar.slider("Terrain Difficulty Weight:", min_value=0.0, max_value=1.0, value=0.5)
|
| 26 |
+
cost_weight = st.sidebar.slider("Cost Weight:", min_value=0.0, max_value=1.0, value=0.5)
|
| 27 |
|
| 28 |
# Display Dataset Options
|
| 29 |
+
data_to_view = st.sidebar.selectbox("Select Dataset to View:", ["Network Insights", "Filtered Terrain Data"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
# Terrain and Connectivity Analysis Section
|
| 32 |
st.header("Terrain and Connectivity Analysis")
|
|
|
|
| 39 |
"Terrain Difficulty (0-10)": np.random.randint(1, 10, size=10),
|
| 40 |
"Signal Strength (dBm)": np.random.randint(-120, -30, size=10),
|
| 41 |
"Cost ($1000s)": np.random.randint(50, 200, size=10),
|
| 42 |
+
"Priority Area": np.random.choice(["Rural", "Urban", "Suburban"], size=10)
|
| 43 |
}
|
| 44 |
return pd.DataFrame(data)
|
| 45 |
|
|
|
|
| 47 |
|
| 48 |
# Filter Data Based on User Inputs
|
| 49 |
filtered_data = terrain_data[
|
| 50 |
+
(terrain_data["Signal Strength (dBm)"] >= signal_threshold) &
|
| 51 |
+
(terrain_data["Cost ($1000s)"] <= budget) &
|
| 52 |
+
(terrain_data["Priority Area"] == priority_area)
|
| 53 |
]
|
| 54 |
|
| 55 |
+
# Add Composite Score for Ranking
|
| 56 |
+
filtered_data["Composite Score"] = (
|
| 57 |
+
(1 - terrain_weight) * filtered_data["Signal Strength (dBm)"] +
|
| 58 |
+
(terrain_weight) * (10 - filtered_data["Terrain Difficulty (0-10)"]) -
|
| 59 |
+
(cost_weight) * filtered_data["Cost ($1000s)"]
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
# Display Selected Dataset
|
| 63 |
+
if data_to_view == "Network Insights":
|
| 64 |
+
st.subheader("Network Insights Dataset")
|
| 65 |
+
st.dataframe(network_insights)
|
| 66 |
+
elif data_to_view == "Filtered Terrain Data":
|
| 67 |
+
st.subheader("Filtered Terrain Data")
|
| 68 |
+
st.dataframe(filtered_data)
|
| 69 |
|
| 70 |
# Visualization
|
| 71 |
fig = px.scatter(
|
|
|
|
| 88 |
def recommend_deployment(data):
|
| 89 |
if data.empty:
|
| 90 |
return "No viable deployment regions within the specified parameters."
|
| 91 |
+
best_region = data.loc[data["Composite Score"].idxmax()]
|
| 92 |
+
return f"Recommended Region: {best_region['Region']} with Composite Score: {best_region['Composite Score']:.2f}, Signal Strength: {best_region['Signal Strength (dBm)']} dBm, Terrain Difficulty: {best_region['Terrain Difficulty (0-10)']}, and Estimated Cost: ${best_region['Cost ($1000s)']}k"
|
| 93 |
|
| 94 |
recommendation = recommend_deployment(filtered_data)
|
| 95 |
st.subheader(recommendation)
|