Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,50 +1,29 @@
|
|
1 |
-
|
2 |
-
import numpy as np
|
3 |
import gradio as gr
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
fig = plt.figure()
|
12 |
-
ax = fig.add_subplot(111)
|
13 |
-
|
14 |
-
for i, crypto in enumerate(cryptocurrencies):
|
15 |
-
series = np.arange(0, year_count, dtype=float)
|
16 |
-
series = series**2 * (i + 1)
|
17 |
-
series += np.random.rand(year_count) * noise
|
18 |
-
ax.plot(x, series, plt_format, label=crypto, color=line_colors[i % len(line_colors)])
|
19 |
-
|
20 |
-
if show_legend:
|
21 |
-
plt.legend()
|
22 |
-
|
23 |
-
ax.set_xlabel("Year")
|
24 |
-
ax.set_ylabel("Value")
|
25 |
-
ax.set_title(f"Cryptocurrency Forecast from {start_year} to {final_year}")
|
26 |
-
|
27 |
-
return fig
|
28 |
|
29 |
-
#
|
30 |
-
|
31 |
-
return
|
|
|
|
|
|
|
|
|
32 |
|
|
|
33 |
demo = gr.Interface(
|
34 |
-
|
35 |
-
[
|
36 |
-
|
37 |
-
|
38 |
-
gr.Slider(1, 100, label="Noise Level", info="Adjust the level of random noise added to the data."),
|
39 |
-
gr.Checkbox(label="Show Legend", info="Toggle the display of the legend."),
|
40 |
-
gr.Dropdown(["cross", "line", "circle"], label="Point Style", info="Choose the marker style for the plot."),
|
41 |
-
gr.ColorPicker(label="Line Colors", value="#1f77b4", info="Choose line colors for the plot.", show_alpha=False), # Color picker for lines
|
42 |
-
],
|
43 |
-
outputs=gr.Plot(label="Forecast Plot", format="png"),
|
44 |
-
layout="vertical", # Improved layout for better organization
|
45 |
-
title="Cryptocurrency Forecasting Tool", # Added title
|
46 |
-
theme="huggingface", # Applying a predefined theme for better look and feel
|
47 |
)
|
48 |
|
49 |
if __name__ == "__main__":
|
50 |
-
demo.launch(
|
|
|
1 |
+
# Import necessary libraries
|
|
|
2 |
import gradio as gr
|
3 |
+
from data_loader import read_dask_data, read_polars_data, read_another_dask_data
|
4 |
|
5 |
+
# Function to handle the data loading logic
|
6 |
+
def load_and_display_data():
|
7 |
+
# Load datasets
|
8 |
+
dask_data = read_dask_data()
|
9 |
+
polars_data = read_polars_data()
|
10 |
+
another_dask_data = read_another_dask_data()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
# Optionally process data (e.g., filter, summarize)
|
13 |
+
# Display the first few rows of the datasets
|
14 |
+
return {
|
15 |
+
"Dask Data from Codeforces Python Submissions": dask_data.head(),
|
16 |
+
"Polars Data from Python Reasoning Dataset": polars_data.head(),
|
17 |
+
"Another Dask Data from Python Github Code": another_dask_data.head()
|
18 |
+
}
|
19 |
|
20 |
+
# Create a Gradio interface to display the data
|
21 |
demo = gr.Interface(
|
22 |
+
load_and_display_data,
|
23 |
+
inputs=[], # No inputs for this simple demo
|
24 |
+
outputs="json", # Display output as a JSON to show data head
|
25 |
+
title="Dataset Loader Demo",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
)
|
27 |
|
28 |
if __name__ == "__main__":
|
29 |
+
demo.launch()
|