Exemplo n.º 1
0
    def get_cluster_graph(self, df_result, label):
        gv = GraphVisualizer()
        gv.set_plotly()
        data_meta_list = []
        for i in OrderedDict.fromkeys(df_result[label]):
            content_label_list = []
            for content_label in df_result[df_result.predict == i]["content"]:
                if len(content_label) > 30:
                    content_label = content_label[:30] + "..."
                    content_label_list.append(content_label)
                else:
                    content_label_list.append(content_label)

            data_meta = {
                "data_name": i,
                "x_data": df_result[df_result[label] == i]["x"],
                "y_data": df_result[df_result[label] == i]["y"],
                "label": content_label_list
            }
            data_meta_list.append(data_meta)
        graph_meta = {
            "title": "Cluter Graph - " + label,
            "x_name": "TSNE X",
            "y_name": "TSNE Y"
        }
        return gv.draw_scatter(data_meta_list, graph_meta)
Exemplo n.º 2
0
 def get_kmeans_graph(self, df_result, label):
     gv = GraphVisualizer()
     gv.set_plotly()
     data_meta_list = []
     for predict in list(OrderedDict.fromkeys(df_result[label])):
         data_meta = {
             "data_name": predict,
             "x_data": df_result[df_result[label]==predict]["x"],
             "y_data": df_result[df_result[label]==predict]["y"],
             "label": predict
         }
         data_meta_list.append(data_meta)
     graph_meta = {
         "title": "K-Means Clutering Graph - " + label,
         "x_name": "TSNE X",
         "y_name": "TSNE Y"
     }
     return gv.draw_scatter(data_meta_list, graph_meta)