Ejemplo n.º 1
0
                def update_lle(m, k_neighbours):
                    main_stats.apply_lle(m=m, k=k_neighbours)
                    lle_vis = VisualizationPlotly(
                        pd_data_frame=main_stats.reduced_pandas_dataframe_lle,
                        column_name=main_stats.label_column).plot_data()

                    return [lle_vis]
Ejemplo n.º 2
0
                def update_pca_box(box_dim):
                    box_plot = VisualizationPlotly(
                        pd_data_frame=main_stats.
                        reduced_pandas_dataframe_isomap
                    ).box_plot_classifications(dim=box_dim - 1)

                    return [box_plot]
Ejemplo n.º 3
0
                def update_pca(m):
                    main_stats.apply_pca(m=m)
                    pca_vis = VisualizationPlotly(
                        pd_data_frame=main_stats.reduced_pandas_dataframe_pca,
                        column_name=main_stats.label_column).plot_data()

                    return [pca_vis]
Ejemplo n.º 4
0
                def update_isomap(m):
                    main_stats.apply_mds(m=m)

                    mds_vis = VisualizationPlotly(
                        pd_data_frame=main_stats.reduced_pandas_dataframe_mds,
                        column_name=main_stats.label_column).plot_data()

                    return [mds_vis]
Ejemplo n.º 5
0
                def update_kmap(m, k_neighbours, a):
                    main_stats.apply_kmap(m=m, k=k_neighbours, a=a)

                    kmap_vis = VisualizationPlotly(
                        pd_data_frame=main_stats.reduced_pandas_dataframe_kmap,
                        column_name=main_stats.label_column).plot_data()

                    return [kmap_vis]
Ejemplo n.º 6
0
                def update_tsne(m, perplexity):
                    main_stats.apply_tsne(m=m, perplexity=perplexity)

                    tsne_vis = VisualizationPlotly(
                        pd_data_frame=main_stats.reduced_pandas_dataframe_tsne,
                        column_name=main_stats.label_column).plot_data()

                    return [tsne_vis]
Ejemplo n.º 7
0
                def update_pca_box(box_dim):
                    print(box_dim)
                    box_plot = VisualizationPlotly(
                        pd_data_frame=main_stats.reduced_pandas_dataframe_pca,
                        column_name=main_stats.label_column
                    ).box_plot_classifications(dim=box_dim - 1)

                    return [box_plot]
Ejemplo n.º 8
0
    def _get_graph(self):
        ''' dashboard with the graphs plots
        '''

        # PCA CASE HERE, right now just 2 plots (scatter and boxplot)
        if self.method == 'PCA':
            visualisation = VisualizationPlotly(pd_data_frame=self.stats.reduced_pandas_dataframe_pca,
                                                column_name=self.stats.label_column)

            # Depending on the plot_options the user selected, produce corresponding plots and append them to the
            # list
            pca_plots = []
            if 'scatter' in self.plot_options:
                scatter_fig = visualisation.plot_data()
                pca_plots.append(html.Div([
                    dcc.Graph(id='reduced_data_plot_pca', figure=scatter_fig)
                ], className='five columns'
                ))

            if 'box' in self.plot_options:
                box_fig = visualisation.box_plot_classifications()
                pca_plots.append(html.Div([
                    dcc.Graph(id='box_outliers_plot_pca', figure=box_fig)
                ], className='five columns'
                ))

            if 'dendrogram' in self.plot_options:
                pca_dendo = visualisation.plot_dendrogram()
                pca_plots.append(html.Div([
                    dcc.Graph(id='dendrogram_pca', figure=pca_dendo),
                ], className='five columns'
                ))

            if 'density' in self.plot_options:
                pca_density = visualisation.plot_data_density()
                pca_plots.append(html.Div([
                    dcc.Graph(id='density_pca', figure=pca_density),
                ], className='five columns'
                ))

            if 'heat' in self.plot_options:
                pca_heat = visualisation.plot_data_heat()
                pca_plots.append(html.Div([
                    dcc.Graph(id='heat_pca', figure=pca_heat),
                ], className='five columns'
                ))

            if 'k' in self.plot_options:
                self.stats.graph_neighbours(n_neighbours=4, algorithm='pca')  # this should be done somewhere else
                pca_graph = visualisation.graph_neighbours(self.stats.edges, self.stats.nodes)
                pca_plots.append(html.Div([
                    dcc.Graph(id='connected_graph_figure_pca', figure=pca_graph),
                ], className='five columns'
                ))

            dashboard = html.Div(children=pca_plots, className="row")

        if self.method == 'LLE':
            visualisation = VisualizationPlotly(pd_data_frame=self.stats.reduced_pandas_dataframe_lle,
                                                column_name=self.stats.label_column)

            # Depending on the plot_options the user selected, produce corresponding plots and append them to the
            # list
            lle_plots = []
            if 'scatter' in self.plot_options:
                scatter_fig_lle = visualisation.plot_data()
                lle_plots.append(html.Div([
                    dcc.Graph(id='reduced_data_plot_lle', figure=scatter_fig_lle)
                ], className='five columns'
                ))

            if 'box' in self.plot_options:
                box_fig_lle = visualisation.box_plot_classifications()
                lle_plots.append(html.Div([
                    dcc.Graph(id='box_outliers_plot_lle', figure=box_fig_lle)
                ], className='five columns'
                ))

            if 'dendrogram' in self.plot_options:
                lle_dendo = visualisation.plot_dendrogram()
                lle_plots.append(html.Div([
                    dcc.Graph(id='dendrogram_lle', figure=lle_dendo),
                ], className='five columns'
                ))

            if 'density' in self.plot_options:
                lle_density = visualisation.plot_data_density()
                lle_plots.append(html.Div([
                    dcc.Graph(id='density_lle', figure=lle_density),
                ], className='five columns'
                ))

            if 'heat' in self.plot_options:
                lle_heat = visualisation.plot_data_heat()
                lle_plots.append(html.Div([
                    dcc.Graph(id='heat_lle', figure=lle_heat),
                ], className='five columns'
                ))

            if 'k' in self.plot_options:
                self.stats.graph_neighbours(n_neighbours=4, algorithm='lle')  # this should be done somewhere else
                lle_graph = visualisation.graph_neighbours(self.stats.edges, self.stats.nodes)
                lle_plots.append(                html.Div([
                    dcc.Graph(id='connected_graph_figure_lle', figure=lle_graph),
                ], className='five columns'
                ))

            dashboard = html.Div(children=lle_plots, className="row")

        if self.method == 'TSNE':
            visualisation = VisualizationPlotly(pd_data_frame=self.stats.reduced_pandas_dataframe_tsne,
                                                column_name=self.stats.label_column)

            # Depending on the plot_options the user selected, produce corresponding plots and append them to the
            # list
            tsne_plots = []
            if 'scatter' in self.plot_options:
                scatter_fig_tsne = visualisation.plot_data()
                tsne_plots.append(html.Div([
                    dcc.Graph(id='reduced_data_plot_tsne', figure=scatter_fig_tsne)
                ], className='five columns'
                ))

            if 'box' in self.plot_options:
                box_fig_tsne = visualisation.box_plot_classifications()
                tsne_plots.append(html.Div([
                    dcc.Graph(id='box_outliers_plot_tsne', figure=box_fig_tsne)
                ], className='five columns'
                ))

            if 'dendrogram' in self.plot_options:
                tsne_dendo = visualisation.plot_dendrogram()
                tsne_plots.append(html.Div([
                    dcc.Graph(id='dendrogram_tsne', figure=tsne_dendo),
                ], className='five columns'
                ))

            if 'density' in self.plot_options:
                tsne_density = visualisation.plot_data_density()
                tsne_plots.append(html.Div([
                    dcc.Graph(id='density_tsne', figure=tsne_density),
                ], className='five columns'
                ))

            if 'heat' in self.plot_options:
                tsne_heat = visualisation.plot_data_heat()
                tsne_plots.append(html.Div([
                    dcc.Graph(id='heat_tsne', figure=tsne_heat),
                ], className='five columns'
                ))

            if 'k' in self.plot_options:
                self.stats.graph_neighbours(n_neighbours=4, algorithm='tsne')  # this should be done somewhere else
                tsne_graph = visualisation.graph_neighbours(self.stats.edges, self.stats.nodes)
                tsne_plots.append(                html.Div([
                    dcc.Graph(id='connected_graph_figure_tsne', figure=tsne_graph),
                ], className='five columns'
                ))

            dashboard = html.Div(children=tsne_plots, className="row")

        if self.method == 'UMAP':
            visualisation = VisualizationPlotly(pd_data_frame=self.stats.reduced_pandas_dataframe_umap,
                                                column_name=self.stats.label_column)

            # Depending on the plot_options the user selected, produce corresponding plots and append them to the
            # list
            umap_plots = []
            if 'scatter' in self.plot_options:
                scatter_fig = visualisation.plot_data()
                umap_plots.append(html.Div([
                    dcc.Graph(id='reduced_data_plot_umap', figure=scatter_fig)
                ], className='five columns'
                ))

            if 'box' in self.plot_options:
                box_fig = visualisation.box_plot_classifications()
                umap_plots.append(html.Div([
                    dcc.Graph(id='box_outliers_plot_umap', figure=box_fig)
                ], className='five columns'
                ))

            if 'dendrogram' in self.plot_options:
                umap_dendo = visualisation.plot_dendrogram()
                umap_plots.append(html.Div([
                    dcc.Graph(id='dendrogram_umap', figure=umap_dendo),
                ], className='five columns'
                ))

            if 'density' in self.plot_options:
                umap_density = visualisation.plot_data_density()
                umap_plots.append(html.Div([
                    dcc.Graph(id='density_umap', figure=umap_density),
                ], className='five columns'
                ))

            if 'heat' in self.plot_options:
                umap_heat = visualisation.plot_data_heat()
                umap_plots.append(html.Div([
                    dcc.Graph(id='heat_umap', figure=umap_heat),
                ], className='five columns'
                ))

            if 'k' in self.plot_options:
                self.stats.graph_neighbours(n_neighbours=4, algorithm='umap')  # this should be done somewhere else
                umap_graph = visualisation.graph_neighbours(self.stats.edges, self.stats.nodes)
                umap_plots.append(html.Div([
                    dcc.Graph(id='connected_graph_figure_umap', figure=umap_graph),
                ], className='five columns'
                ))

            dashboard = html.Div(children=umap_plots, className="row")

        if self.method == 'KMAP':
            visualisation = VisualizationPlotly(pd_data_frame=self.stats.reduced_pandas_dataframe_kmap,
                                                column_name=self.stats.label_column)

            # Depending on the plot_options the user selected, produce corresponding plots and append them to the
            # list
            kmap_plots = []
            if 'scatter' in self.plot_options:
                scatter_fig = visualisation.plot_data()
                kmap_plots.append(html.Div([
                    dcc.Graph(id='reduced_data_plot_kmap', figure=scatter_fig)
                ], className='five columns'
                ))

            if 'box' in self.plot_options:
                box_fig = visualisation.box_plot_classifications()
                kmap_plots.append(html.Div([
                    dcc.Graph(id='box_outliers_plot_kmap', figure=box_fig)
                ], className='five columns'
                ))

            if 'dendrogram' in self.plot_options:
                kmap_dendo = visualisation.plot_dendrogram()
                kmap_plots.append(html.Div([
                    dcc.Graph(id='dendrogram_kmap', figure=kmap_dendo),
                ], className='five columns'
                ))

            if 'density' in self.plot_options:
                kmap_density = visualisation.plot_data_density()
                kmap_plots.append(html.Div([
                    dcc.Graph(id='density_kmap', figure=kmap_density),
                ], className='five columns'
                ))

            if 'heat' in self.plot_options:
                kmap_heat = visualisation.plot_data_heat()
                kmap_plots.append(html.Div([
                    dcc.Graph(id='heat_kmap', figure=kmap_heat),
                ], className='five columns'
                ))

            if 'k' in self.plot_options:
                self.stats.graph_neighbours(n_neighbours=4, algorithm='kmap')  # this should be done somewhere else
                kmap_graph = visualisation.graph_neighbours(self.stats.edges, self.stats.nodes)
                kmap_plots.append(html.Div([
                    dcc.Graph(id='connected_graph_figure_kmap', figure=kmap_graph),
                ], className='five columns'
                ))

            dashboard = html.Div(children=kmap_plots, className="row")

        if self.method == 'ISOMAP':
            visualisation = VisualizationPlotly(pd_data_frame=self.stats.reduced_pandas_dataframe_isomap,
                                                column_name=self.stats.label_column)

            # Depending on the plot_options the user selected, produce corresponding plots and append them to the
            # list
            isomap_plots = []
            if 'scatter' in self.plot_options:
                scatter_fig = visualisation.plot_data()
                isomap_plots.append(html.Div([
                    dcc.Graph(id='reduced_data_plot_isomap', figure=scatter_fig)
                ], className='five columns'
                ))

            if 'box' in self.plot_options:
                box_fig = visualisation.box_plot_classifications()
                isomap_plots.append(html.Div([
                    dcc.Graph(id='box_outliers_plot_isomap', figure=box_fig)
                ], className='five columns'
                ))

            if 'dendrogram' in self.plot_options:
                isomap_dendo = visualisation.plot_dendrogram()
                isomap_plots.append(html.Div([
                    dcc.Graph(id='dendrogram_isomap', figure=isomap_dendo),
                ], className='five columns'
                ))

            if 'density' in self.plot_options:
                isomap_density = visualisation.plot_data_density()
                isomap_plots.append(html.Div([
                    dcc.Graph(id='density_isomap', figure=isomap_density),
                ], className='five columns'
                ))

            if 'heat' in self.plot_options:
                isomap_heat = visualisation.plot_data_heat()
                isomap_plots.append(html.Div([
                    dcc.Graph(id='heat_isomap', figure=isomap_heat),
                ], className='five columns'
                ))

            if 'k' in self.plot_options:
                self.stats.graph_neighbours(n_neighbours=4, algorithm='isomap')  # this should be done somewhere else
                isomap_graph = visualisation.graph_neighbours(self.stats.edges, self.stats.nodes)
                isomap_plots.append(html.Div([
                    dcc.Graph(id='connected_graph_figure_isomap', figure=isomap_graph),
                ], className='five columns'
                ))

            dashboard = html.Div(children=isomap_plots, className="row")

        if self.method == 'MDS':
            visualisation = VisualizationPlotly(pd_data_frame=self.stats.reduced_pandas_dataframe_mds,
                                                column_name=self.stats.label_column)

            # Depending on the plot_options the user selected, produce corresponding plots and append them to the
            # list
            mds_plots = []
            if 'scatter' in self.plot_options:
                scatter_fig = visualisation.plot_data()
                mds_plots.append(html.Div([
                    dcc.Graph(id='reduced_data_plot_mds', figure=scatter_fig)
                ], className='five columns'
                ))

            if 'box' in self.plot_options:
                box_fig = visualisation.box_plot_classifications()
                mds_plots.append(html.Div([
                    dcc.Graph(id='box_outliers_plot_mds', figure=box_fig)
                ], className='five columns'
                ))

            if 'dendrogram' in self.plot_options:
                mds_dendo = visualisation.plot_dendrogram()
                mds_plots.append(html.Div([
                    dcc.Graph(id='dendrogram_mds', figure=mds_dendo),
                ], className='five columns'
                ))

            if 'density' in self.plot_options:
                mds_density = visualisation.plot_data_density()
                mds_plots.append(html.Div([
                    dcc.Graph(id='density_mds', figure=mds_density),
                ], className='five columns'
                ))

            if 'heat' in self.plot_options:
                mds_heat = visualisation.plot_data_heat()
                mds_plots.append(html.Div([
                    dcc.Graph(id='heat_mds', figure=mds_heat),
                ], className='five columns'
                ))

            if 'k' in self.plot_options:
                self.stats.graph_neighbours(n_neighbours=4, algorithm='mds')  # this should be done somewhere else
                mds_graph = visualisation.graph_neighbours(self.stats.edges, self.stats.nodes)
                mds_plots.append(html.Div([
                    dcc.Graph(id='connected_graph_figure_mds', figure=mds_graph),
                ], className='five columns'
                ))

            dashboard = html.Div(children=mds_plots, className="row")

        return dashboard