def save_plot(name, threshold, save_name='default', level="INFO"): from view import plot_utils path = resource_manager.Properties.getDefaultDataFold( ) + "result/temp/" + name + "/" + save_name + "/" "threshold.png" plot_utils.save_scatter_diagram(None, x=threshold['d_c'].values, y=threshold['H'].values, x_label='delta', y_label='H', title='threshold scatter figure', path=path) plot_utils.save_scatter_diagram(None, x=threshold['d_c'].values, y=threshold['H'].values, x_label='delta', y_label='H', title='threshold scatter figure', path=path) if level == "DEBUG": plot_utils.plot_scatter_diagram(None, x=threshold['d_c'].values, y=threshold['H'].values, x_label='delta', y_label='H', title='threshold scatter figure') plot_utils.plot_scatter_diagram(None, x=threshold['H'].values, y=threshold['d_c'].values, x_label='delta', y_label='H', title='threshold scatter figure')
def save_show_cluster(index_id, data, distance_c, pile_id, dataset="/", level="INFO", level_info='scatter figure'): from view import plot_utils from context import resource_manager path = resource_manager.Properties.getDefaultDataFold() + "result" + resource_manager.getSeparator() + "temp/" + dataset + "/" + resource_manager.Properties.name_str_static() + "/" level_path = resource_manager.Properties.getDefaultDataFold() + "result" + resource_manager.getSeparator() + "temp/" + level + "/" + resource_manager.Properties.name_str_static() + "/" + str( distance_c) + "/" if not os.path.exists(path[:path.rfind('/')]): os.makedirs(path[:path.rfind('/')]) if not os.path.exists(level_path[:level_path.rfind('/')]): os.makedirs(level_path[:level_path.rfind('/')]) pile_id = pile_id.sort_values('size', ascending=False) x = [] y = [] label = [] i = 1 for m in range(len(pile_id)): # l=pile_id.irow(m)['pile'] l = pile_id.iloc[m]['pile'] # size=pile_id.irow(m)['size'] size = pile_id.iloc[m]['size'] if pile_id.loc[m]['outlier'] is False: for node in l: index = index_id[node] x.append(data[index][0]) y.append(data[index][1]) label.append(i) i = i + 1 else: for node in l: index = index_id[node] x.append(data[index][0]) y.append(data[index][1]) label.append(0) if level is "SEE": plot_utils.plot_scatter_diagram(None, x=x, y=y, x_label='x', y_label='y', title=level_info, label=label) if level is "DEBUG": # plot_utils.save_scatter_diagram(None, x=x, y=y, x_label='x', y_label='y', title='scatter figure', label=label,path=level_path+resource_manager.Properties.name_str_FULL()+".png") plot_utils.save_all_scatter_diagram(None, x=x, y=y, x_label='x', y_label='y', title=level_info, label=label, path=level_path + resource_manager.Properties.name_str_FULL() + ".png") else: plot_utils.save_scatter_diagram(None, x=x, y=y, x_label='x', y_label='y', title='scatter figure', label=label, path=path + str( distance_c) + ".png") plot_utils.save_all_scatter_diagram(None, x=x, y=y, x_label='x', y_label='y', title='scatter figure', label=label, path=path + str( distance_c) + ".png") # plot_utils.plot_scatter_diagram(None, x=x, y=y, x_label='x', y_label='y', title='scatter figure', label=label) log.debug(("\n") + str(pile_id)) try: p = Properties.getDefaultDataFold() + "/csv/" + dataset + "/" + resource_manager.Properties.name_str_static() + "/" + str( distance_c) + ".csv" pile_id.to_csv(p) except: if not os.path.exists(p[:p.rfind('/')]): pp = p.rfind('/') os.makedirs(p[:pp]) os.mknod(p) pile_id.to_csv(p)
def save_show_cluster(index_id, data, distance_c, pile_id): from view import plot_utils from context import resource_manager path = resource_manager.Properties.getDefaultDataFold( ) + "result" + resource_manager.getSeparator( ) + "temp" + resource_manager.getSeparator( ) + resource_manager.Properties.name_str_static( ) + resource_manager.getSeparator() + str(distance_c) + ".png" if not os.path.exists(resource_manager.Properties.getDefaultDataFold() + "result" + resource_manager.getSeparator() + "temp" + resource_manager.getSeparator() + resource_manager.Properties.name_str_static() + resource_manager.getSeparator()): os.makedirs(resource_manager.Properties.getDefaultDataFold() + "result" + resource_manager.getSeparator() + "temp" + resource_manager.getSeparator() + resource_manager.Properties.name_str_static() + resource_manager.getSeparator()) pile_id = pile_id.sort_values('size', ascending=False) x = [] y = [] label = [] i = 1 for m in range(len(pile_id)): # l=pile_id.irow(m)['pile'] l = pile_id.iloc[m]['pile'] # size=pile_id.irow(m)['size'] size = pile_id.iloc[m]['size'] if size >= 1 and i < 15: for node in l: index = index_id[node] x.append(data[index][0]) y.append(data[index][1]) label.append(i) i = i + 1 else: for node in l: index = index_id[node] x.append(data[index][0]) y.append(data[index][1]) label.append(0) plot_utils.save_scatter_diagram(None, x=x, y=y, x_label='x', y_label='y', title='scatter figure', label=label, path=path) # plot_utils.plot_scatter_diagram(None, x=x, y=y, x_label='x', y_label='y', title='scatter figure', label=label) log.debug(pile_id) try: p = Properties.getDefaultDataFold( ) + "/csv/" + resource_manager.Properties.name_str_static( ) + "/" + str(distance_c) + ".csv" pile_id.to_csv(p) except: if not os.path.exists(p): pp = p.rfind('/') os.makedirs(p[:pp]) os.mknod(p) pile_id.to_csv(p)
def load_data(): id = np.load(Properties.getRootPath() + "/data/cache/flame/id.npy") data = np.load(Properties.getRootPath() + "/data/cache/flame/data.npy") return id, data if __name__ == '__main__': id, data = load_data() label = [int(x[0:1]) for x in id] from context.resource_manager import Properties from view import shape_view from view import plot_utils from cluster import density_cluster x = data[:, :1] y = data[:, 1:2] path = resource_manager.Properties.getDefaultDataFold( ) + resource_manager.getSeparator( ) + "result" + resource_manager.getSeparator() + "srv.png" plot_utils.save_scatter_diagram(None, x=x, y=y, x_label='x', y_label='y', title='scatter figure', label=label, path=path) #plot_utils.plot_scatter_diagram(None,x=x,y=y,x_label='x',y_label='y',title='scatter figure',label=label)