File size: 1,437 Bytes
ed86caa
 
 
 
 
 
 
 
 
53c16fa
ed86caa
 
53c16fa
ed86caa
 
d560675
a6ef4e5
 
 
 
 
ed86caa
a6ef4e5
 
 
3432ce2
ed86caa
 
 
 
 
 
53c16fa
d560675
ed86caa
 
53c16fa
ed86caa
 
06ba366
 
ed86caa
 
fe8e91b
ed86caa
53c16fa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np

import gradio as gr


def plot_forecast(final_year, companies, noise, show_legend, point_style):
    start_year = 2020
    x = np.arange(start_year, final_year + 1)
    year_count = x.shape[0]
    plt_format = ({"cross": "X", "line": "-", "circle": "o--"})[point_style]
    fig = plt.figure()
    ax = fig.add_subplot(111)
    for i, company in enumerate(["Google", "Microsoft", "Netflix", "Apple", "Amazon", "Facebook"]):
        if company in companies:
            series = np.arange(0, year_count, dtype=float)
            series = series**2 * (i + 1)
            series += np.random.rand(year_count) * noise
            ax.plot(x, series, plt_format, label=company)
    if show_legend:
        plt.legend()
    ax.set_xlabel("Year")
    ax.set_ylabel("Revenue")
    ax.set_title("Pricescope Forecast")
    return fig


demo = gr.Interface(
    plot_forecast,
    [
        gr.Radio([2025, 2030, 2035, 2040], label="Project to:"),
        gr.CheckboxGroup(["Google", "Microsoft", "Netflix","Apple", "Amazon", "Facebook"], label="Company Selection"),
        gr.Slider(1, 100, label="Noise Level"),
        gr.Checkbox(label="Show Legend"),
        gr.Dropdown(["cross", "line", "circle"], label="Style"),
    ],
    gr.Plot(label="forecast"),
    title="PRICESCOPE: THE FUTURE OF THE STOCKS"

)


if __name__ == "__main__":
    demo.launch()