Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import matplotlib
|
2 |
+
matplotlib.use('Agg')
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
import gradio as gr
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
title="Financial: THE REAL FUTURE OF THE STOCKS"
|
11 |
+
|
12 |
+
|
13 |
+
def plot_forecast(final_year, companies, noise, show_legend, point_style):
|
14 |
+
start_year = 2020
|
15 |
+
x = np.arange(start_year, final_year + 1)
|
16 |
+
year_count = x.shape[0]
|
17 |
+
plt_format = ({"cross": "X", "line": "-", "circle": "o--"})[point_style]
|
18 |
+
fig = plt.figure()
|
19 |
+
ax = fig.add_subplot(111)
|
20 |
+
for i, company in enumerate(["Google", "Microsoft", "Netflix", "Apple", "Amazon", "Facebook"]):
|
21 |
+
if company in companies:
|
22 |
+
series = np.arange(0, year_count, dtype=float)
|
23 |
+
series = series**2 * (i + 1)
|
24 |
+
series += np.random.rand(year_count) * noise
|
25 |
+
ax.plot(x, series, plt_format, label=company)
|
26 |
+
if show_legend:
|
27 |
+
plt.legend()
|
28 |
+
ax.set_xlabel("Year")
|
29 |
+
ax.set_ylabel("Revenue")
|
30 |
+
ax.set_title("Pricescope Forecast")
|
31 |
+
return fig
|
32 |
+
|
33 |
+
|
34 |
+
demo = gr.Interface(
|
35 |
+
plot_forecast,
|
36 |
+
[
|
37 |
+
gr.Radio([2025, 2030, 2035, 2040], label="Project to:"),
|
38 |
+
gr.CheckboxGroup(["Google", "Microsoft", "Netflix","Apple", "Amazon", "Facebook"], label="Company Selection"),
|
39 |
+
gr.Slider(1, 100, label="Noise Level"),
|
40 |
+
gr.Checkbox(label="Show Legend"),
|
41 |
+
gr.Dropdown(["cross", "line", "circle"], label="Style"),
|
42 |
+
],
|
43 |
+
gr.Plot(label="forecast"),
|
44 |
+
title = title
|
45 |
+
)
|
46 |
+
|
47 |
+
import gradio as gr
|
48 |
+
|
49 |
+
gr.Interface.load("models/runaksh/financial_sentiment_distilBERT")
|
50 |
+
|
51 |
+
if __name__ == "__main__":
|
52 |
+
demo.launch()
|