""" ******************************************************* Owner: Ashutosh Jha For: APPCAIR BITS Pilani Goa Campus, Reflexis Systems Function Name: CheckIfBelongs Takes head, current row, row number and target column as input, checks for three cases 1) if current instance satisfies the condition in node and prediction matches actual label, 2) if current instance only satisfies condition and labels do not match and 3) if node's condition is not satisfied. ******************************************************* """ from exec_node import exec_node def CheckIfBelongs(head,cur_row,z,target_col): try: exec_node(head,cur_row,z) except TypeError: print("Log: Encountered a None node or an NaN value in row no:",z) #print(head.belongs) if(target_col != None): if(head.belongs == True): if(head.pred_label == cur_row[target_col]): print("Row no.",z,"belongs to the node",head.name) return 1 else: print("Row no.",z,"does not belong to the node",head.name) return 2 else: print("Row no.",z,"does not belong to the node",head.name) return 3 else: if(head.belongs == True): print("Row no.",z,"belongs to the node",head.name) return 4 else: print("Row no.",z,"does not belong to the node",head.name) return 5