Spaces:
Sleeping
Sleeping
File size: 3,189 Bytes
b61df43 |
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 |
import streamlit as st
import pandas as pd
import numpy as np
import plotly.express as px
from transformers import pipeline
from datasets import load_dataset
# Hugging Face Datasets
@st.cache_data
def load_data():
network_insights = load_dataset("huggingface/infrastructure-insights", split="train")
broadband_forecast = load_dataset("huggingface/broadband-access-forecast", split="train")
return network_insights.to_pandas(), broadband_forecast.to_pandas()
# Load Datasets
network_insights, broadband_forecast = load_data()
# Title
st.title("Smart Network Infrastructure Planner")
st.sidebar.header("Input Parameters")
# User Inputs from Sidebar
budget = st.sidebar.number_input("Total Budget (in $1000s):", min_value=10, max_value=1000, step=10)
priority_area = st.sidebar.selectbox("Priority Area:", ["Rural", "Urban", "Suburban"])
signal_threshold = st.sidebar.slider("Signal Strength Threshold (dBm):", min_value=-120, max_value=-30, value=-80)
# Display Dataset Options
data_to_view = st.sidebar.selectbox("Select Dataset to View:", ["Network Insights", "Broadband Forecast"])
# Display Selected Dataset
if data_to_view == "Network Insights":
st.subheader("Network Insights Dataset")
st.dataframe(network_insights)
else:
st.subheader("Broadband Forecast Dataset")
st.dataframe(broadband_forecast)
# Terrain and Connectivity Analysis Section
st.header("Terrain and Connectivity Analysis")
# Simulate Terrain Data
def generate_terrain_data():
np.random.seed(42)
data = {
"Region": [f"Region-{i}" for i in range(1, 11)],
"Terrain Difficulty (0-10)": np.random.randint(1, 10, size=10),
"Signal Strength (dBm)": np.random.randint(-120, -30, size=10),
"Cost ($1000s)": np.random.randint(50, 200, size=10),
}
return pd.DataFrame(data)
terrain_data = generate_terrain_data()
# Filter Data Based on User Inputs
filtered_data = terrain_data[
(terrain_data["Signal Strength (dBm)"] >= signal_threshold) & (terrain_data["Cost ($1000s)"] <= budget)
]
# Display Filtered Results
st.write("Filtered Results Based on Inputs:")
st.dataframe(filtered_data)
# Visualization
fig = px.scatter(
filtered_data,
x="Cost ($1000s)",
y="Signal Strength (dBm)",
size="Terrain Difficulty (0-10)",
color="Region",
title="Signal Strength vs. Cost",
labels={
"Cost ($1000s)": "Cost in $1000s",
"Signal Strength (dBm)": "Signal Strength in dBm",
},
)
st.plotly_chart(fig)
# Recommendation Engine
st.header("Deployment Recommendations")
def recommend_deployment(data):
if data.empty:
return "No viable deployment regions within the specified parameters."
best_region = data.loc[data["Signal Strength (dBm)"].idxmax()]
return f"Recommended Region: {best_region['Region']} with Signal Strength: {best_region['Signal Strength (dBm)']} dBm and Estimated Cost: ${best_region['Cost ($1000s)']}k"
recommendation = recommend_deployment(filtered_data)
st.subheader(recommendation)
# Footer
st.sidebar.markdown("---")
st.sidebar.markdown(
"**Developed for Hackathon using Hugging Face Infinite Dataset Hub**\n\n[Visit Hugging Face](https://huggingface.co)")
|