Spaces:
Sleeping
Sleeping
Commit
·
71ecb21
1
Parent(s):
d48b64d
add app from alex
Browse files- .python-version +1 -0
- .streamlit/config.toml +2 -0
- app.py +71 -2
- hello.py +6 -0
- pyproject.toml +7 -0
- requirements.txt +46 -0
- validation/2017.csv +0 -0
- validation/2018.csv +0 -0
- validation/2019.csv +0 -0
- validation/2020.csv +0 -0
- validation/2021.csv +0 -0
- validation/2022.csv +0 -0
.python-version
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
3.12
|
.streamlit/config.toml
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
base = "light"
|
app.py
CHANGED
@@ -1,4 +1,73 @@
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import matplotlib.pyplot as plt
|
2 |
+
import pandas as pd
|
3 |
import streamlit as st
|
4 |
|
5 |
+
|
6 |
+
def load_data(year):
|
7 |
+
"""Load data from a CSV file for the given year."""
|
8 |
+
try:
|
9 |
+
data = pd.read_csv(f"validation/{year}.csv")
|
10 |
+
return data
|
11 |
+
except FileNotFoundError:
|
12 |
+
st.error(f"No data found for year {year}. Please ensure the file exists.")
|
13 |
+
return None
|
14 |
+
|
15 |
+
def filter_data(data, country, brand):
|
16 |
+
"""Filter the data for the selected country and brand."""
|
17 |
+
return data[(data['country'] == country) & (data['brand'] == brand)]
|
18 |
+
|
19 |
+
def plot_data(filtered_data):
|
20 |
+
"""Plot target vs. date with a confidence interval."""
|
21 |
+
if filtered_data.empty:
|
22 |
+
st.warning("No data available for the selected criteria.")
|
23 |
+
return
|
24 |
+
|
25 |
+
st.write("Plotting target vs date with confidence intervals.")
|
26 |
+
dates = pd.to_datetime(filtered_data['date'])
|
27 |
+
target = filtered_data['target']
|
28 |
+
prediction = filtered_data['prediction']
|
29 |
+
prediction_10 = filtered_data['prediction_10']
|
30 |
+
prediction_90 = filtered_data['prediction_90']
|
31 |
+
|
32 |
+
plt.figure(figsize=(12, 6))
|
33 |
+
|
34 |
+
# Plot the target
|
35 |
+
plt.plot(dates, target, label='Target', color='blue')
|
36 |
+
|
37 |
+
# Plot the prediction with confidence interval
|
38 |
+
plt.plot(dates, prediction, label='Prediction', color='orange')
|
39 |
+
plt.fill_between(dates, prediction_10, prediction_90, color='orange', alpha=0.2, label='Confidence Interval (10th to 90th percentile)')
|
40 |
+
|
41 |
+
plt.xlabel('Date')
|
42 |
+
plt.ylabel('Target')
|
43 |
+
plt.title('Target vs Date with Confidence Interval')
|
44 |
+
plt.legend()
|
45 |
+
plt.grid(True)
|
46 |
+
st.pyplot(plt)
|
47 |
+
|
48 |
+
def main():
|
49 |
+
st.title("Data Visualization App")
|
50 |
+
|
51 |
+
# Step 1: Select Year
|
52 |
+
year = st.sidebar.selectbox("Select Year", range(2017, 2022))
|
53 |
+
|
54 |
+
# Load data based on year selection
|
55 |
+
data = load_data(year)
|
56 |
+
|
57 |
+
if data is not None:
|
58 |
+
# Step 2: Select Country based on available options for the year
|
59 |
+
available_countries = data['country'].unique()
|
60 |
+
country = st.sidebar.selectbox("Select Country", available_countries)
|
61 |
+
|
62 |
+
# Step 3: Select Brand based on available options for the year and country
|
63 |
+
available_brands = data[data['country'] == country]['brand'].unique()
|
64 |
+
brand = st.sidebar.selectbox("Select Brand", available_brands)
|
65 |
+
|
66 |
+
# Filter data based on inputs
|
67 |
+
filtered_data = filter_data(data, country, brand)
|
68 |
+
|
69 |
+
# Plot the data
|
70 |
+
plot_data(filtered_data)
|
71 |
+
|
72 |
+
if __name__ == "__main__":
|
73 |
+
main()
|
hello.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def main():
|
2 |
+
print("Hello from novartis!")
|
3 |
+
|
4 |
+
|
5 |
+
if __name__ == "__main__":
|
6 |
+
main()
|
pyproject.toml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[project]
|
2 |
+
name = "novartis"
|
3 |
+
version = "0.1.0"
|
4 |
+
description = "Add your description here"
|
5 |
+
readme = "README.md"
|
6 |
+
requires-python = ">=3.12"
|
7 |
+
dependencies = []
|
requirements.txt
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
altair==5.5.0
|
2 |
+
attrs==24.2.0
|
3 |
+
blinker==1.9.0
|
4 |
+
cachetools==5.5.0
|
5 |
+
certifi==2024.8.30
|
6 |
+
charset-normalizer==3.4.0
|
7 |
+
click==8.1.7
|
8 |
+
contourpy==1.3.1
|
9 |
+
cycler==0.12.1
|
10 |
+
fonttools==4.55.0
|
11 |
+
gitdb==4.0.11
|
12 |
+
gitpython==3.1.43
|
13 |
+
idna==3.10
|
14 |
+
jinja2==3.1.4
|
15 |
+
jsonschema==4.23.0
|
16 |
+
jsonschema-specifications==2024.10.1
|
17 |
+
kiwisolver==1.4.7
|
18 |
+
markdown-it-py==3.0.0
|
19 |
+
markupsafe==3.0.2
|
20 |
+
matplotlib==3.9.3
|
21 |
+
mdurl==0.1.2
|
22 |
+
narwhals==1.15.0
|
23 |
+
numpy==2.1.3
|
24 |
+
packaging==24.2
|
25 |
+
pandas==2.2.3
|
26 |
+
pillow==11.0.0
|
27 |
+
protobuf==5.29.0
|
28 |
+
pyarrow==18.1.0
|
29 |
+
pydeck==0.9.1
|
30 |
+
pygments==2.18.0
|
31 |
+
pyparsing==3.2.0
|
32 |
+
python-dateutil==2.9.0.post0
|
33 |
+
pytz==2024.2
|
34 |
+
referencing==0.35.1
|
35 |
+
requests==2.32.3
|
36 |
+
rich==13.9.4
|
37 |
+
rpds-py==0.21.0
|
38 |
+
six==1.16.0
|
39 |
+
smmap==5.0.1
|
40 |
+
streamlit==1.40.2
|
41 |
+
tenacity==9.0.0
|
42 |
+
toml==0.10.2
|
43 |
+
tornado==6.4.2
|
44 |
+
typing-extensions==4.12.2
|
45 |
+
tzdata==2024.2
|
46 |
+
urllib3==2.2.3
|
validation/2017.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
validation/2018.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
validation/2019.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
validation/2020.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
validation/2021.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
validation/2022.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|