File size: 7,558 Bytes
5a8a0ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import gradio as gr
import pandas as pd
import plotly.express as px
import matplotlib.pyplot as plt
import statistics

LIBRARIES = ["ALOY", "APSTUD", "CLI", "TIMOB", "XD"]

def grafico(list_output_mean, list_output_neosp, nome_projeto, pip_choices):
    list_output_mean = [3.152778, 3.375000, 1.423820, 1.052039, 1.297747, 1.224785, 2.250000, 2.375000, 1.540773, 1.847639, 1.491953, 1.052039, 0.983369, 1.669528, 1.665236, 1.412554, 1.375000, 1.078326, 1.556330, 1.625000, 1.860515, 1.491953, 1.160944, 1.675966, 1.987661, 2.369099, 1.431867, 1.944742, 2.329399, 1.925429]
    list_output_NEOSP = [3.191631, 3.417342, 1.202562, 0.867979, 1.225224, 1.028501, 2.165318, 2.291910, 1.141041, 1.785504, 1.086850, 0.875381, 0.714992, 1.604599, 1.833541, 0.860600, 1.393656, 1.152935, 1.364006, 1.647414, 1.527748, 1.236909, 1.403306, 1.655692, 1.770828, 1.937058, 0.861534, 1.341726, 1.904503, 1.449757]
    list_results = [ ["Median Regressor", statistics.mean(list_output_mean)], ["NEOSP-SVR Regressor", statistics.mean(list_output_NEOSP)] ]
    fig, (ax1, ax2) = plt.subplots(1, 2)
    # ax1
    if "Median Regressor" in pip_choices:
        df_list_output_mean = pd.DataFrame(list_output_mean, columns=["MAE"])   
        ax1.plot(df_list_output_mean.index, df_list_output_mean["MAE"],  label="Median Regressor")
    if "NEOSP-SVR Regressor" in pip_choices:
        df_list_output_NEOSP = pd.DataFrame(list_output_NEOSP, columns=["MAE"])
        ax1.plot(df_list_output_NEOSP.index, df_list_output_NEOSP["MAE"], label="NEOSP-SVR Regressor")
    ax1.set_xlabel("Index Execução")
    ax1.set_ylabel("MAE")
    ax1.legend()
    # ax2
    if "Median Regressor" or "NEOSP-SVR Regressor" in pip_choices:
        df = pd.DataFrame(list_results, columns = ["Model","MAE"])    
    if "Median Regressor" in pip_choices:
        ax2.bar(df["Model"].iloc[[0]], df["MAE"].iloc[[0]])
    if "NEOSP-SVR Regressor" in pip_choices:
        ax2.bar(df["Model"].iloc[[1]], df["MAE"].iloc[[1]])
    if "NEOSP-SVR Regressor" and "NEOSP-SVR Regressor" in pip_choices:
        ax2.bar(df["Model"], df["MAE"])
    if "Median Regressor" or "NEOSP-SVR Regressor" in pip_choices:
        ax2.set_ylabel("MAE Médio")
        ax2.set_xlabel("Modelos")
    # graficos geral
    fig.set_figwidth(15) 
    fig.set_figheight(4) 
    fig.suptitle("Projeto {}".format(nome_projeto))
    return gr.update(value=plt, visible=True)

def create_pip_plot(libraries, pip_choices):
    if "ALOY" in libraries:
        list_output_ALOY_mean = [3.152778, 3.375000, 1.423820, 1.052039, 1.297747, 1.224785, 2.250000, 2.375000, 1.540773, 1.847639, 1.491953, 1.052039, 0.983369, 1.669528, 1.665236, 1.412554, 1.375000, 1.078326, 1.556330, 1.625000, 1.860515, 1.491953, 1.160944, 1.675966, 1.987661, 2.369099, 1.431867, 1.944742, 2.329399, 1.925429]
        list_output_ALOY_NEOSP = [3.191631, 3.417342, 1.202562, 0.867979, 1.225224, 1.028501, 2.165318, 2.291910, 1.141041, 1.785504, 1.086850, 0.875381, 0.714992, 1.604599, 1.833541, 0.860600, 1.393656, 1.152935, 1.364006, 1.647414, 1.527748, 1.236909, 1.403306, 1.655692, 1.770828, 1.937058, 0.861534, 1.341726, 1.904503, 1.449757]
        return grafico(list_output_ALOY_mean, list_output_ALOY_NEOSP, "ALOY", pip_choices)
    elif "APSTUD" in libraries:
        list_output_ALOY_mean = [3.152778, 3.375000, 1.423820, 1.052039, 1.297747, 1.224785, 2.250000, 2.375000, 1.540773, 1.847639, 1.491953, 1.052039, 0.983369, 1.669528, 1.665236, 1.412554, 1.375000, 1.078326, 1.556330, 1.625000, 1.860515, 1.491953, 1.160944, 1.675966, 1.987661, 2.369099, 1.431867, 1.944742, 2.329399, 1.925429]
        list_output_ALOY_NEOSP = [3.191631, 3.417342, 1.202562, 0.867979, 1.225224, 1.028501, 2.165318, 2.291910, 1.141041, 1.785504, 1.086850, 0.875381, 0.714992, 1.604599, 1.833541, 0.860600, 1.393656, 1.152935, 1.364006, 1.647414, 1.527748, 1.236909, 1.403306, 1.655692, 1.770828, 1.937058, 0.861534, 1.341726, 1.904503, 1.449757]
        return grafico(list_output_ALOY_mean, list_output_ALOY_NEOSP, "APSTUD", pip_choices)
    elif "CLI" in libraries:
        list_output_ALOY_mean = [3.152778, 3.375000, 1.423820, 1.052039, 1.297747, 1.224785, 2.250000, 2.375000, 1.540773, 1.847639, 1.491953, 1.052039, 0.983369, 1.669528, 1.665236, 1.412554, 1.375000, 1.078326, 1.556330, 1.625000, 1.860515, 1.491953, 1.160944, 1.675966, 1.987661, 2.369099, 1.431867, 1.944742, 2.329399, 1.925429]
        list_output_ALOY_NEOSP = [3.191631, 3.417342, 1.202562, 0.867979, 1.225224, 1.028501, 2.165318, 2.291910, 1.141041, 1.785504, 1.086850, 0.875381, 0.714992, 1.604599, 1.833541, 0.860600, 1.393656, 1.152935, 1.364006, 1.647414, 1.527748, 1.236909, 1.403306, 1.655692, 1.770828, 1.937058, 0.861534, 1.341726, 1.904503, 1.449757]
        return grafico(list_output_ALOY_mean, list_output_ALOY_NEOSP, "CLI", pip_choices)
    elif "TIMOB" in libraries:        
        list_output_ALOY_mean = [3.152778, 3.375000, 1.423820, 1.052039, 1.297747, 1.224785, 2.250000, 2.375000, 1.540773, 1.847639, 1.491953, 1.052039, 0.983369, 1.669528, 1.665236, 1.412554, 1.375000, 1.078326, 1.556330, 1.625000, 1.860515, 1.491953, 1.160944, 1.675966, 1.987661, 2.369099, 1.431867, 1.944742, 2.329399, 1.925429]
        list_output_ALOY_NEOSP = [3.191631, 3.417342, 1.202562, 0.867979, 1.225224, 1.028501, 2.165318, 2.291910, 1.141041, 1.785504, 1.086850, 0.875381, 0.714992, 1.604599, 1.833541, 0.860600, 1.393656, 1.152935, 1.364006, 1.647414, 1.527748, 1.236909, 1.403306, 1.655692, 1.770828, 1.937058, 0.861534, 1.341726, 1.904503, 1.449757]
        return grafico(list_output_ALOY_mean, list_output_ALOY_NEOSP, "TIMOB", pip_choices)
    elif "XD" in libraries:
        list_output_ALOY_mean = [3.152778, 3.375000, 1.423820, 1.052039, 1.297747, 1.224785, 2.250000, 2.375000, 1.540773, 1.847639, 1.491953, 1.052039, 0.983369, 1.669528, 1.665236, 1.412554, 1.375000, 1.078326, 1.556330, 1.625000, 1.860515, 1.491953, 1.160944, 1.675966, 1.987661, 2.369099, 1.431867, 1.944742, 2.329399, 1.925429]
        list_output_ALOY_NEOSP = [3.191631, 3.417342, 1.202562, 0.867979, 1.225224, 1.028501, 2.165318, 2.291910, 1.141041, 1.785504, 1.086850, 0.875381, 0.714992, 1.604599, 1.833541, 0.860600, 1.393656, 1.152935, 1.364006, 1.647414, 1.527748, 1.236909, 1.403306, 1.655692, 1.770828, 1.937058, 0.861534, 1.341726, 1.904503, 1.449757]
        return grafico(list_output_ALOY_mean, list_output_ALOY_NEOSP, "XD", pip_choices)
    else:
        return gr.update(visible=True)
    
with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            gr.Markdown("## Conjunto de Dados")
            libraries = gr.Dropdown(choices=LIBRARIES, label="Projeto", value= "ALOY")
        with gr.Column():
            gr.Markdown("## Gráficos")
            pip = gr.CheckboxGroup(choices=["Median Regressor", "NEOSP-SVR Regressor"], label="Modelos Preditivos")
            #stars = gr.CheckboxGroup(choices=["Stars", "Week over Week"], label="")
            #issues = gr.CheckboxGroup(choices=["Issue", "Exclude org members", "week over week"], label="")
    with gr.Row():
        fetch = gr.Button(value="Fetch")
    with gr.Row():
        with gr.Column():
            pip_plot = gr.Plot(visible=False)
            #star_plot = gr.Plot(visible=False)
            #issue_plot = gr.Plot(visible=False)

    fetch.click(create_pip_plot, inputs=[libraries, pip], outputs=pip_plot)
    #fetch.click(create_star_plot, inputs=[libraries, pip], outputs=star_plot)
    #fetch.click(create_issue_plot, inputs=[libraries, issues], outputs=issue_plot)

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