예제 #1
0
    def plot(self) -> List[dcc.Graph]:
        apps = self.model.apps
        data_compounds = [
            dc
            for dc in self.model.get_all_data_compounds_with_sane_data()
            if dc.get_aggregation_level() == AggregationLevel.APP
        ]

        self.print_latex_table(data_compounds)

        html_elements = []
        html_elements.append(header_metric("Distribution Table"))

        dt = dash_table.DataTable(
            data=self.get_table_data(data_compounds),
            columns=self.get_columns(),
            style_cell={
                'textAlign': 'left',
            },
            style_header={
                'backgroundColor': colorconstants.RGB_COLOR_LIGHT_GREY,
            },
            merge_duplicate_headers=True,
            # style_data_conditional=style_data_conditional,
        )
        html_elements.append(dt)

        html_elements.append(header_metric("Histogram Plots"))
        histogram_plots = self.get_histogram_plots(data_compounds)
        html_elements.append(histogram_plots)

        return html_elements
예제 #2
0
    def plot(self):
        html_elements = []

        apps = sorted(self.model.apps)
        matrix = self.load_data(apps)

        df = pd.DataFrame({
            'domain': [app.domain for app in apps],
            'package_name': [app.package_name for app in apps],
            'app': apps
        })

        by_domain = df.groupby("domain")
        for domain, frame in by_domain:
            domain_apps = [app for app in frame["app"]]
            use_cases = sorted([
                use_case.name for use_case in
                self.model.use_case_manager.get_use_cases_for_domain(domain)
            ])
            html_elements.append(
                header_metric(f"Use Case Overview: {domain.value}"))
            dt = self.get_overview_table(domain_apps, use_cases, matrix)
            html_elements.append(dt)

        bar_plots, layout = self.get_verified_use_case_execution_stacked_bar_charts(
            apps, matrix)
        html_elements.append(
            header_metric(
                "Use Case Executions Overview Stacked Bar Chart: Distribution of apps among verified use case executions"
            ))
        graph = dcc.Graph(
            id=USE_CASE_EXECUTIONS_OVERVIEW_STACKED_BAR_CHART_GRAPH_ID,
            config=dict(displayModeBar=False),
            figure=dict(data=bar_plots, layout=layout))
        html_elements.append(graph)

        bar_plots, layout = self.get_number_computed_verified_grouped_bar_chart(
            apps, matrix)
        html_elements.append(
            header_metric(
                "Use Case Executions Computed Verified Overview Stacked Bar Chart"
            ))
        graph = dcc.Graph(
            id=
            USE_CASE_EXECUTIONS_COMPUTED_VERIFIED_OVERVIEW_STACKED_BAR_CHART_GRAPH_ID,
            config=dict(displayModeBar=False),
            figure=dict(data=bar_plots, layout=layout))
        html_elements.append(graph)

        return dbc.Container(id=self.get_ui_id(), children=html_elements)
예제 #3
0
 def ui_element(cls, show_header=True):
     assert cls.description is not None
     children = []
     if show_header:
         children.append(header_metric(cls.description))
     children.append(dcc.Loading(id=cls.get_ui_loading_id(), children=[], type="circle"))
     return dbc.Container(children)
예제 #4
0
    def get_correlation_graph(self):
        apps = sorted(self.model.apps)
        matrix = self.load_data(apps)
        use_cases_all = self.model.use_case_manager.get_use_cases()
        number_of_atds = self.calculate_number_of_atds(use_cases_all)
        number_of_words = self.calculate_number_of_words(use_cases_all)
        number_of_verified_uce = self.calculate_number_of_verified_use_case_executions(
            apps, matrix, use_cases_all)
        number_of_computed_uce = self.calculate_number_of_computed_use_case_executions(
            apps, matrix, use_cases_all)

        df = pd.DataFrame({
            "Number of ATDs": number_of_atds,
            "Number of words in use case": number_of_words,
            "Number of computed UCEs": number_of_computed_uce,
            "Number of verified UCEs": number_of_verified_uce,
        })

        # method = "pearson"
        methods = [
            'pearson',  # Gaussian or Gaussian-like distribution
            'spearman',
            'kendall',
        ]
        height = 500
        width = 600

        html_elements = []
        for method in methods:
            title = f'Correlation Matrix ({method})'
            html_elements.append(header_metric(title))
            corr = statisticsutil.calc_correlation_matrix(df, method)
            heat, layout = plotutil.get_correlations_heatmap(corr)

            graph = dcc.Graph(id=f"correlation-graph-{method}",
                              style={
                                  'height': f'{height}px',
                                  'width': f'{width}px',
                              },
                              config=dict(displayModeBar=False),
                              figure=dict(data=[heat], layout=layout))

            if configutil.MATRICS_FIGURE_DUMP_PLOTS:
                plotutil.write_plot_to_file(
                    [heat],
                    layout,
                    f"{USE_CASE_EXECUTIONS_CORRELATION_HEATMAP_GRAPH_ID}-{method}",
                    width=width,
                    height=height)

            html_elements.append(graph)

        return html_elements
예제 #5
0
    def plot(self) -> List[dcc.Graph]:
        html_elements = []
        apps = self.model.apps
        data_compounds: List[DataCompound] = [
            dc for dc in self.model.get_all_data_compounds_with_sane_data()
            if dc.get_aggregation_level() == AggregationLevel.APP and dc.name
            not in PlayStoreCorrelationsMetricAppAL.filtered_metrics
        ]

        for aggr_func, aggr_func_name in PlayStoreCorrelationsMetricAppAL.aggregation_functions:
            # All valid metrics data for a correlation analysis
            metrics_data = {
                f"{dc.name}": self.aggregate_data(aggr_func, dc.data)
                for dc in data_compounds
                if len(self.aggregate_data(aggr_func, dc.data)) == len(apps)
            }
            assert len(metrics_data), f"Metrics data was empty"

            metrics_df = pd.DataFrame(metrics_data)
            for method in PlayStoreCorrelationsMetricAppAL.methods:
                title = f'Correlation Matrix ({method}) ({aggr_func_name})'
                html_elements.append(header_metric(title))
                corr = statisticsutil.calc_correlation_matrix(
                    metrics_df, method, white_list)
                heat, layout = plotutil.get_correlations_heatmap(
                    corr, triangle=False)

                graph = dcc.Graph(
                    id=
                    f"play-store-correlation-graph-{method}-{aggr_func_name}",
                    style={
                        'height':
                        f'{PlayStoreCorrelationsMetricAppAL.height}px',
                        'width': f'{PlayStoreCorrelationsMetricAppAL.width}px',
                    },
                    config=dict(displayModeBar=False),
                    figure=dict(data=[heat], layout=layout))

                if configutil.MATRICS_FIGURE_DUMP_PLOTS:
                    plotutil.write_plot_to_file(
                        [heat],
                        layout,
                        f"{PlayStoreCorrelationsMetricAppAL.get_id()}-{method}-{aggr_func_name}",
                        width=PlayStoreCorrelationsMetricAppAL.width,
                        height=PlayStoreCorrelationsMetricAppAL.height)

                html_elements.append(graph)

        return html_elements
예제 #6
0
def model_use_case_base_unmodified_graph_ctr(app_selectionv):
    model_html_children = []
    if hasattr(app, 'matrics_'):
        model_metrics: ModelGraphs = app.matrics_.model.model_accessors[
            modelmetrics.ModelGraphs.get_id()]
        model_graphs = model_metrics.plot_use_case_base_unmodified_graph()
        sel = app_selectionv
        model_graph = list(
            model_graphs.values())[0] if sel is None else model_graphs[sel]
        model_html_children = [
            header_metric("Base unmodified graph for use case identification"),
            dbc.Container(id=f'Base use case transformed graph {sel}',
                          children=model_graph,
                          style={"border": "1px solid black"})
        ]

    return model_html_children
예제 #7
0
def model_app_home_state_graph_ctr(app_selectionv):
    model_html_children = []
    if hasattr(app, 'matrics_'):
        model_metrics: ModelGraphs = app.matrics_.model.model_accessors[
            modelmetrics.ModelGraphs.get_id()]
        model_graphs = model_metrics.get_app_home_state_graphs()
        sel = app_selectionv
        model_graph = list(
            model_graphs.values())[0] if sel is None else model_graphs[sel]
        model_html_children = [
            header_metric(
                "Base graph for use case identification with tagged app home state"
            ),
            dbc.Container(id=f'model-app-home-state-graph-{sel}-div',
                          children=model_graph,
                          style={
                              "border": "1px solid black",
                              "width": configutil.MATRICS_VISUALIZATION_WIDTH
                          })
        ]

    return model_html_children