def MKNN_init(self): #setting up configuration GraphClusterer_WI_semisupervised.configdata.do_config() GraphClusterer_WI_semisupervised.configdata.data_dir logger = GraphClusterer_WI_semisupervised.configdata.logger logger.debug("Debugging from inside MKNN_init method") #setting up the input matrices #Create SM and SM_orig GraphClusterer_WI_semisupervised.graphdata.create_SM_from_relfile( GraphClusterer_WI_semisupervised.configdata.inp_rel_file) #Expand SM GraphClusterer_WI_semisupervised.graphdata.setup_expanded_SM( GraphClusterer_WI_semisupervised.configdata.nhops, GraphClusterer_WI_semisupervised.configdata.inp_rel_file) #Create Edge Objects GraphClusterer_WI_semisupervised.graphdata.create_edge_objects() #self.helper.print_dict(GraphClusterer.graphdata.edge_dict) #self.helper.print_set(GraphClusterer.graphdata.node_dict[1].node_edges_dict[EdgeType.secondary]) #print(GraphClusterer.graphdata.edge_dict[011].edge_id) #Initialize all K evaluation objects for both phases self.phase1_allKevaluationdata = AllKEvaluationData( self.configdata, 1) #1 for phase=1 self.phase2_allKevaluationdata = AllKEvaluationData( self.configdata, 2) #2 for phase=2
def clusterone_init(self): #setting up configuration GraphClusterer_Clusterone_semisupervised.configdata.do_config() GraphClusterer_Clusterone_semisupervised.configdata.data_dir logger = GraphClusterer_Clusterone_semisupervised.configdata.logger logger.debug("Debugging from inside MKNN_init method") GraphClusterer_Clusterone_semisupervised.graphdata = GraphData_Clusterone_Gene( GraphClusterer_Clusterone_semisupervised.configdata.GO_TYPE, GraphClusterer_Clusterone_semisupervised.configdata.GO_SIZE, GraphClusterer_Clusterone_semisupervised.configdata.GO_SIM_TYPE, GraphClusterer_Clusterone_semisupervised.configdata.go_obo_file, GraphClusterer_Clusterone_semisupervised.configdata.gene_syn_file) #Create SM and SM_orig GraphClusterer_Clusterone_semisupervised.graphdata.create_SM_from_relfile( GraphClusterer_Clusterone_semisupervised.configdata.inp_rel_file) #Expansion step not needed here as in MKNN GraphClusterer_Clusterone_semisupervised.graphdata.setup_SM_GO_1( GraphClusterer_Clusterone_semisupervised.configdata.inp_rel_file, GraphClusterer_Clusterone_semisupervised.configdata.gene2go_file) #Create edge objects GraphClusterer_Clusterone_semisupervised.graphdata.create_edge_objects( ) #Initialize all K evaluation objects for both phases self.phase1_allKevaluationdata = AllKEvaluationData( self.configdata, 1) #1 for phase=1 self.phase2_allKevaluationdata = AllKEvaluationData( self.configdata, 2) #2 for phase=2
def clusterone_init(self): #setting up configuration GraphClusterer_Clusterone_CP_Overlapping.configdata.do_config() GraphClusterer_Clusterone_CP_Overlapping.configdata.data_dir logger = GraphClusterer_Clusterone_CP_Overlapping.configdata.logger logger.debug("Debugging from inside MKNN_init method.") #Create SM and SM_orig GraphClusterer_Clusterone_CP_Overlapping.graphdata.create_SM_from_relfile(GraphClusterer_Clusterone_CP_Overlapping.configdata.inp_rel_file) #Expansion step not needed here as in MKNN #Create edge objects GraphClusterer_Clusterone_CP_Overlapping.graphdata.create_edge_objects() #Initialize all K evaluation objects for both phases self.phase1_allKevaluationdata = AllKEvaluationData(self.configdata, 1) #1 for phase=1 self.phase2_allKevaluationdata = AllKEvaluationData(self.configdata, 2) #2 for phase=2
class GraphClusterer_WI_semisupervised(object): CODE_DIR = '/Users/divya/work/repo/Dissertation' #CODE_DIR = '/Users/divya/Documents/Dissertation/Dissertation' DATA_DIR = '/Users/divya/Documents/input/Dissertation/data' LOG_DIR = '/Users/divya/Documents/logs/Dissertation' configdata = ConfigData(CODE_DIR, DATA_DIR, LOG_DIR) #graphdata = GraphData_Gene(GO_SIM_TYPE) graphdata = None def __init__(self, K): self.phase1data = None self.phase2data = None self.phase1_allKevaluationdata = None self.phase2_allKevaluationdata = None self.helper = MKNN_Helper() #self.GO_SIM_TYPE = 'BP' ############################################################## #1. Initialize MKNN #2. As a wrapper, call MKNN_worker for different values of K ############################################################## def MKNN_worker_wrapper(self): #GraphClusterer.configdata.logger.info("Initialization phase of GMKNN begins") self.MKNN_init() GraphClusterer_WI_semisupervised.configdata.logger.info( "Initialization phase of GMKNN ends.") GraphClusterer_WI_semisupervised.configdata.logger.info( "Working of G-MKNN begins") GraphClusterer_WI_semisupervised.configdata.logger.info( "Running G-MKNN for different values of K.") K_range = list( range( (int)(GraphClusterer_WI_semisupervised.configdata.K_min), (int)(GraphClusterer_WI_semisupervised.configdata.K_max) + 1)) for K in K_range: GraphClusterer_WI_semisupervised.configdata.logger.info( "Running G-MKNN for the value of K: ") GraphClusterer_WI_semisupervised.configdata.logger.info(K) #Call MKNN_worker for the value of K self.MKNN_worker(K) #(CL_List_P2, CL_List_P1, SM, SM_orig, num_clusters_P2, num_clusters_P1, num_nodes) = MKNN_worker(K, max_num_clusters, SM, SM_orig, num_nodes, node_codes, currentdate_str, dataset_name, eval_results_dir, log) #Plot evaluation measures for all values of K for phase 1 self.phase1_allKevaluationdata.plot_evaluation_measures_for_all_K() #Plot evaluation measures for all values of K for phase 2 self.phase2_allKevaluationdata.plot_evaluation_measures_for_all_K() ############################################ #Set up configuration #Set up the input matrices for the algorithm ############################################ def MKNN_init(self): #setting up configuration GraphClusterer_WI_semisupervised.configdata.do_config() GraphClusterer_WI_semisupervised.configdata.data_dir logger = GraphClusterer_WI_semisupervised.configdata.logger logger.debug("Debugging from inside MKNN_init method") #Instantiate GraphData_Gene GraphClusterer_WI_semisupervised.graphdata = GraphData_Gene( GraphClusterer_WI_semisupervised.configdata.GO_TYPE, GraphClusterer_WI_semisupervised.configdata.GO_SIZE, GraphClusterer_WI_semisupervised.configdata.GO_SIM_TYPE, GraphClusterer_WI_semisupervised.configdata.go_obo_file, GraphClusterer_WI_semisupervised.configdata.gene_syn_file) #setting up the input matrices #Create SM and SM_orig GraphClusterer_WI_semisupervised.graphdata.create_SM_from_relfile( GraphClusterer_WI_semisupervised.configdata.inp_rel_file) #Expand SM #GraphClusterer_WI_semisupervised.graphdata.setup_expanded_SM(GraphClusterer_WI_semisupervised.configdata.nhops, GraphClusterer_WI_semisupervised.configdata.inp_rel_file) #Setup GOsim based SM_GO #GraphClusterer_WI_semisupervised.graphdata.setup_SM_GO(GraphClusterer_WI_semisupervised.configdata.inp_rel_file, GraphClusterer_WI_semisupervised.configdata.gene2go_file) GraphClusterer_WI_semisupervised.graphdata.setup_SM_GO_1( GraphClusterer_WI_semisupervised.configdata.inp_rel_file, GraphClusterer_WI_semisupervised.configdata.gene2go_file) #Create Edge Objects GraphClusterer_WI_semisupervised.graphdata.create_edge_objects() #self.helper.print_dict(GraphClusterer.graphdata.edge_dict) #self.helper.print_set(GraphClusterer.graphdata.node_dict[1].node_edges_dict[EdgeType.secondary]) #print(GraphClusterer.graphdata.edge_dict[011].edge_id) #Initialize all K evaluation objects for both phases self.phase1_allKevaluationdata = AllKEvaluationData( self.configdata, 1) #1 for phase=1 self.phase2_allKevaluationdata = AllKEvaluationData( self.configdata, 2) #2 for phase=2 print("MKNN_Init phase complete.") ############################# #Run MKNN for one value of K ############################# def MKNN_worker(self, K): self.phase1data = Phase1Data_WI_Gene( GraphClusterer_WI_semisupervised.graphdata, GraphClusterer_WI_semisupervised.configdata, K) self.MKNN_Phase1() self.phase2data = Phase2Data_WI_Gene( GraphClusterer_WI_semisupervised.graphdata, GraphClusterer_WI_semisupervised.configdata, K, self.phase1data.cnodes_dict, self.phase1data.next_cluster_label, self.phase1data.num_clusters) self.MKNN_Phase2() def MKNN_Phase1(self): #Initialize Phase 1 self.phase1data.initialize_phase() #self.helper.print_list(self.phase1data.graphdata.node_dict[10].MKNN_list) #print('Degree') #print((self.phase1data.graphdata.node_dict[10].degree)) #print('CI_list') #self.helper.print_list(self.phase1data.cluster_initiator_list) #self.helper.convert_list_ids_to_codes(self.graphdata, self.phase1data.cluster_initiator_list) #print((self.phase1data.graphdata.CI_list[0])) #Execute Phase 1 self.phase1data.execute_phase() #Visualize Phase 1 results self.phase1data.visualize_phase() #Evaluate phase self.phase1data.evaluate_phase() self.phase1_allKevaluationdata.add_evaluation_for_K( self.phase1data.phase1_evaluation_data) print("MKNN_Phase1 complete.") def MKNN_Phase2(self): #Initialize phase 2 self.phase2data.initialize_phase() #self.helper.print_list(self.phase2data.c_SM) #self.helper.print_list(self.phase2data.c_SM_sort) #Execute phase 2 self.phase2data.execute_phase() #Visualize phase self.phase2data.visualize_phase() #Evaluate Phase self.phase2data.evaluate_phase() self.phase2_allKevaluationdata.add_evaluation_for_K( self.phase2data.phase2_evaluation_data) #self.helper.print_list(self.phase2data.phase2_evaluation_data.gold_standard_CL_list) self.helper.print_list( self.phase2data.phase2_evaluation_data.contingency_matrix) print("sensitivity:") print(self.phase2data.phase2_evaluation_data.sensitivity) print("PPV") print(self.phase2data.phase2_evaluation_data.PPV) print("accuracy") print(self.phase2data.phase2_evaluation_data.accuracy)