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 show_cluster(index_id, data, distance_c, pile_id): from view import plot_utils 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.plot_scatter_diagram(None, x=x, y=y, x_label='x', y_label='y', title='scatter figure', label=label) log.debug(pile_id)
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)
if __name__ == '__main__': get_threshold() from context.resource_manager import Properties from view import shape_view from view import plot_utils from cluster import density_cluster threshold = pandas.read_csv(Properties.getDefaultDataFold() + "/csv/threshold.csv") d_c = np.asarray(threshold['d_c'].values) log.debug(d_c) log.critical(type(d_c)) plot_utils.plot_scatter_diagram(None, x=d_c, y=threshold['H'].values, x_label='delta', y_label='H', title='threshold scatter figure') """ delta_index=Series(id,index=id,dtype=np.float) i=0 order_id=Series(result[:,0],index=id_index.values) # to find the rho_j>rho_i order_id=order_id.sort_values() j=order_id.index[1] # to find the j=int(index_id[j]) # to find the i'key k=str(id_index[i])