import Generate import numpy import copy num_feature = 4 hypo_table = Generate.Boundary_Hypo_Table(num_feature) num_hypo = len(hypo_table) x = numpy.array(range(num_feature)) for a in range(num_feature): t = numpy.random.randint(0, num_feature) x[t], x[a] = x[a], x[t] print(x) observation_steps = 2 # How many observations we want k_matrix = numpy.zeros((num_hypo, num_hypo)) for tr in range(num_hypo): '''True hypothesis''' true_hypo = hypo_table[tr] print(true_hypo) temp = list(range(num_hypo)) print("temp", temp) for idx in range(observation_steps): '''Search for the matching''' c_idx = x[idx] # The current feature index c_label = true_hypo[c_idx] for i in range(num_hypo): if c_label != hypo_table[i][c_idx]:
# Tree Model import numpy import Utility import copy import Generate # Generate the hypothesis matrix total_features = 4 hypo = Generate.Boundary_Hypo_Table(total_features, True) total_hypos = len(hypo) # Create the observation list arr = "" for x in range(total_features): arr += str(x) obs_list = numpy.array(list(Utility.Permutation(arr)), dtype=int) lst_size = len(obs_list) print(obs_list) best_route = {} # Count how many observations counting = 0 for true_idx in range(total_hypos): # Create the true hypo true_hypo = hypo[true_idx] print("True hypothesis = ", true_hypo) maximum = 0
import AL import Generate import Const #hypo = Generate.Uniform_Hypo_Table(1, False) ''' task = AL.ActiveLearning(knowledgeability=1) Generate.Transfer_User_Table(Const.user_hypo_table, Const.label_map) print(Const.user_hypo_table)P task.Set(user_hypo=Const.user_hypo_table) task.O_Task() ''' task = AL.ActiveLearning(knowledgeability=1) task.Set(user_hypo=Generate.Boundary_Hypo_Table(4, True)) task.DS_Task()
import Generate import numpy import tensorflow import time import copy # =============================== # ====== [Hyperparameters] ====== # =============================== num_feature = 20 num_label = 2 knowledgeability = 1 iteration = 100 hypo_matrix = Generate.Boundary_Hypo_Table(num_feature, True) num_hypo = len(hypo_matrix) ptxy = 1 / num_feature / num_label # =============================== # ====== [Numpy Matrix] ========= # ====== [Memory Usage Note] ==== # ====== [1000 Features] ======== # ====== [About 300 MB RAM] ===== # =============================== # PYXH Matrix P_y_xh = numpy.empty((num_label, num_feature, num_hypo), dtype="float32") # Knowledgeability Matrix Delta_g_h = numpy.zeros((num_hypo, num_hypo), dtype="float32")