S-Dreamer commited on
Commit
72d7898
·
verified ·
1 Parent(s): 7eb356c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -42
app.py CHANGED
@@ -1,50 +1,29 @@
1
- import matplotlib.pyplot as plt
2
- import numpy as np
3
  import gradio as gr
 
4
 
5
- def plot_forecast(final_year, cryptocurrencies, noise, show_legend, point_style, line_colors):
6
- start_year = 2020
7
- x = np.arange(start_year, final_year + 1)
8
- year_count = x.shape[0]
9
- plt_format = ({"cross": "X", "line": "-", "circle": "o--"})[point_style]
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
- # Create a color palette for the plot
30
- def generate_color_palette():
31
- return ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd"]
 
 
 
 
32
 
 
33
  demo = gr.Interface(
34
- plot_forecast,
35
- [
36
- gr.Radio([2025, 2030, 2035, 2040], label="Project to:", info="Select the forecast year."),
37
- gr.CheckboxGroup(["Bitcoin", "Ethereum", "Litecoin"], label="Cryptocurrency Selection", info="Choose which cryptocurrencies to forecast."),
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(show_error=True)
 
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()