def plot3(alphabet_sizes, data_size=400, missingness_parameter=0.1, dl="me", minsup=0.02): similarity_list = [] for alphabet_size in alphabet_sizes: positives = [] negatives = [] while len(positives) == 0 or len(negatives) == 0: actual_theory = generate_theory(alphabet_size) theory_object = GeneratedTheory(actual_theory) generator = TheoryNoisyGeneratorOnDataset(theory_object, data_size, missingness_parameter) positives, negatives = generator.generate_dataset() learned_theory, _ = Mistle(positives, negatives).learn(dl_measure=dl, minsup=minsup) learned_clauses = get_clauses(learned_theory) similarity = compare_theories(actual_theory, learned_clauses, alphabet_size) similarity_list.append(similarity) # print(similarity_list) return similarity_list
def plot1(data_sizes, alphabet_size=14, missingness_parameter=0.1, dl="me", minsup=0.02): similarity_list = [] for data_size in data_sizes: positives = [] negatives = [] while len(positives) == 0 or len(negatives) == 0: actual_theory = [] while actual_theory == []: actual_theory = generate_complex_theory( alphabet_size, clause_size=(2, alphabet_size)) if solve([tuple(clause) for clause in actual_theory]) == "UNSAT": print("Generated theory is not SAT\t: " + str(actual_theory)) actual_theory = [] theory_object = GeneratedTheory(actual_theory) generator = TheoryNoisyGeneratorOnDataset(theory_object, data_size, missingness_parameter) positives, negatives = generator.generate_dataset() learned_theory, _ = Mistle(positives, negatives).learn(dl_measure=dl, minsup=minsup) learned_clauses = get_clauses(learned_theory) similarity = compare_theories(actual_theory, learned_clauses, alphabet_size) similarity_list.append(similarity) return similarity_list
samp_positives_list = [] samp_negatives_list = [] samp_unique_positives_list = [] samp_unique_negatives_list = [] overlap_size_list = [] # simple_theory_list = [] # for i in range(iterations): # simple_theory_list.append(generate_theory(alphabet_size)) for i in range(iterations): print("\n\n==================== New Iteration [" + str(i) + "] ====================") actual_theory = complex_theory_list[i] # actual_theory = simple_theory_list.pop() theory_object = GeneratedTheory(actual_theory) generator = TheoryNoisyGeneratorOnDataset(theory_object, data_size, missingness_parameter) positives, negatives = generator.generate_dataset() samp_positives = len(positives) samp_negatives = len(negatives) samp_unique_positives = len(set(positives)) samp_unique_negatives = len(set(negatives)) if samp_positives == 0: print(i, "Sampled Positives are empty") if samp_negatives == 0: print(i, "Sampled Negatives are empty") if balance: