def run(): problems = [ 'llvm_input', 'noc_CM_log', 'sort_256', 'wc+rs-3d-c4', 'wc+sol-3d-c4', 'wc+wc-3d-c4', 'wc-3d-c4', 'wc-5d-c5', 'wc-6d-c1', 'wc-c1-3d-c1', 'wc-c3-3d-c1', 'rs-6d-c3' ] for problem in problems: print ">>> ", problem if problem == 'wc-3d-c4': files = [ "./Data/" + f for f in os.listdir("./Data") if problem in f ] files = [f for f in files if '+' not in f] else: files = [ "./Data/" + f for f in os.listdir("./Data") if problem in f ] assert (len(files) == 20), "Somethign is wrong" for file in files: # if "POM" in file: # name = file.split('/')[-1].split('_')[0] # indeps, deps = collect_all_points(file, 9, 3) # elif "xomo" in file: # if "xomoo2" in file: # name = "xomoo2" # else: # name = "_".join(file.split('/')[-1].split('_')[:2]) # indeps, deps = collect_all_points(file, 27, 4) # elif "MONRP" in file: # name = "_".join(file.split('/')[-1].split('_')[:6]) # indeps, deps = collect_all_points(file, 50, 3) name = file.split('/')[-1].split('_')[0] indeps, deps = collect_all_points(file, None, 2) keys = lessismore.keys() if name == 'wc-3d-c4': key = [k for k in keys if name in k] key = [k for k in key if '+' not in k] else: key = [k for k in keys if name in k] try: assert (len(key) == 1), "Something is wrong" except: import pdb pdb.set_trace() key = key[0] transformed_training_dep = get_cdom_values(deps, lessismore[key]) assert (len(deps) == len(transformed_training_dep) ), "Something is wrong" from sklearn.tree import DecisionTreeRegressor, export_graphviz model = DecisionTreeRegressor(min_samples_leaf=2) model.fit(indeps, transformed_training_dep) tree_name = "./tree/" + file.split('/')[-1][:-4] + '.dot' export_graphviz(model, out_file=tree_name) print tree_name
def parallelize(subdir, name, rep_no, decisions, objectives): print subdir, name, rep_no indeps, deps = collect_all_points(subdir, decisions, objectives) keys = lessismore.keys() key = [k for k in keys if name in k] try: assert (len(key) == 1), "Something is wrong" except: import pdb pdb.set_trace() key = key[0] transformed_training_dep = get_cdom_values(deps, lessismore[key]) assert (len(deps) == len(transformed_training_dep)), "Something is wrong" from sklearn.tree import DecisionTreeRegressor, export_graphviz model = DecisionTreeRegressor(min_samples_leaf=2) model.fit(indeps, transformed_training_dep) tree_name = "./tree/" + name + "_" + str(rep_no) + '.dot' export_graphviz(model, out_file=tree_name) print tree_name
dep = [] content = open(file).readlines() for c in content: indep.append(map(int, map(float, c.strip().split(';')))) temp = ",".join( map(str, map(int, map(float, c.strip().split(';'))))) try: dep.append(objectives_dict[temp]) except: import pdb pdb.set_trace() assert (len(indep) == len(dep)), "Something is wrong" # appropriate key for lessismore keys = lessismore.keys() if name == 'wc-3d-c4': key = "./Data/wc-3d-c4.csv" else: key = [k for k in keys if name in k.lower()] try: assert (len(key) == 1), "Something is wrong" except: import pdb pdb.set_trace() key = key[0] transformed_training_dep = get_cdom_values(dep, lessismore[key]) assert ( len(dep) == len(transformed_training_dep)), "Something is wrong" from sklearn.tree import DecisionTreeRegressor, export_graphviz model = DecisionTreeRegressor(min_samples_leaf=2)