Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
# Load the largest hospitals data
|
6 |
+
data = [
|
7 |
+
{"Hospital": "Texas Health Presbyterian Hospital Dallas", "City": "Dallas", "State": "TX", "Beds": 898},
|
8 |
+
{"Hospital": "Cedars-Sinai Medical Center", "City": "Los Angeles", "State": "CA", "Beds": 886},
|
9 |
+
{"Hospital": "Jackson Memorial Hospital", "City": "Miami", "State": "FL", "Beds": 1618},
|
10 |
+
{"Hospital": "New York-Presbyterian Hospital", "City": "New York", "State": "NY", "Beds": 2528},
|
11 |
+
{"Hospital": "Barnes-Jewish Hospital", "City": "St. Louis", "State": "MO", "Beds": 1252},
|
12 |
+
]
|
13 |
+
|
14 |
+
# Create a Pandas DataFrame from the data
|
15 |
+
df = pd.DataFrame(data)
|
16 |
+
|
17 |
+
# Define the generative AI function
|
18 |
+
def generate_data(df, num_rows=1):
|
19 |
+
# Calculate the mean and standard deviation of the Beds column
|
20 |
+
bed_mean = df["Beds"].mean()
|
21 |
+
bed_std = df["Beds"].std()
|
22 |
+
|
23 |
+
# Generate new data using a normal distribution
|
24 |
+
new_data = {
|
25 |
+
"Hospital": [f"Generated Hospital {i}" for i in range(num_rows)],
|
26 |
+
"City": np.random.choice(df["City"], num_rows),
|
27 |
+
"State": np.random.choice(df["State"], num_rows),
|
28 |
+
"Beds": np.random.normal(bed_mean, bed_std, num_rows).astype(int)
|
29 |
+
}
|
30 |
+
|
31 |
+
# Create a new DataFrame from the generated data and return it
|
32 |
+
return pd.DataFrame(new_data)
|
33 |
+
|
34 |
+
# Define the Streamlit app
|
35 |
+
def app():
|
36 |
+
st.title("Generative AI Demo")
|
37 |
+
|
38 |
+
# Display the original data
|
39 |
+
st.subheader("Original Data")
|
40 |
+
st.write(df)
|
41 |
+
|
42 |
+
# Generate new data and display it
|
43 |
+
st.subheader("Generated Data")
|
44 |
+
num_rows = st.slider("Number of rows to generate", min_value=1, max_value=100, value=1)
|
45 |
+
new_data = generate_data(df, num_rows=num_rows)
|
46 |
+
st.write(new_data)
|
47 |
+
|
48 |
+
# Run the Streamlit app
|
49 |
+
if __name__ == "__main__":
|
50 |
+
app()
|