def evaluate(prob, input=None): if input: for i, decision in enumerate(prob.decisions): decision.value = input[i] input = [decision.value for decision in prob.decisions] k = int(input[0]) t_nol = int(input[1]) from modify_ecl_file import modify_file from random import randint modify_file( prob.dataset_name, prob.features, [randint(1, prob.instances) for _ in xrange(k)], t_nol, prob.conv, prob.tuning_instances, ) print "# ", sys.stdout.flush() command = 'ecl run /home/vnair2/GIT/HPCCTuning/Problems/HPCC/Kmeans/kmeans.ecl -I"/home/vnair2/GIT/ecl-ml" --target=thor' import subprocess DEVNULL = open(os.devnull, "wb") output = subprocess.check_output(command, shell=True) result = output.split("\n")[3] import re res = re.search(r"_1>(.*)</Result_1>", result) return_value = int(res.group(1)) return [return_value]
def evaluate(prob, input=None): if input: for i, decision in enumerate(prob.decisions): decision.value = input[i] input = [decision.value for decision in prob.decisions] no_trees = int(input[0]) no_features = int(input[1]) purity = input[2] depth = int(input[3]) from modify_ecl_file import modify_file from random import randint modify_file(prob.dataset_name, no_trees, no_features, purity, depth) print "# ", sys.stdout.flush() command = 'ecl run c:\\GIT\\HPCCTuning\\Problems\\HPCC\\RF\\rf.ecl -I"c:\\GIT\\HPCCTuning\\ecl-ml" --target=hthor --server=10.239.227.6 --port=8010' import subprocess DEVNULL = open(os.devnull, "wb") output = subprocess.check_output(command, shell=True) result = output.split("\n")[3] import re res = re.search(r"accuracy>(.*)</accuracy>", result) return_value = res.group(1) return [1 - float(return_value)] # Since max value of accuracy = 1
def hpcc_rf(parameter): from modify_ecl_file import modify_file from random import randint modify_file(parameter[0], parameter[1], parameter[2], parameter[3], parameter[4]) from time import sleep sleep(1) print "# ", sys.stdout.flush() command = "ecl run ./Problems/RF/rf.ecl -I\"/home/vnair2/GIT/ecl-ml\" --target=thor" import subprocess DEVNULL = open(os.devnull, "wb") output = subprocess.check_output(command, shell=True) import xml.etree.ElementTree as ET tree = ET.ElementTree(ET.fromstring(output)) accuracy = float(tree.getroot().find("Dataset").find("Row").find("accuracy").text) return accuracy
def hpcc_rf(parameter): from modify_ecl_file import modify_file from random import randint modify_file(parameter[0], parameter[1], parameter[2], parameter[3], parameter[4]) from time import sleep sleep(1) print "# ", sys.stdout.flush() command = "ecl run ./Problems/RF/rf.ecl -I\"/home/vnair2/GIT/ecl-ml\" --target=thor" import subprocess DEVNULL = open(os.devnull, "wb") output = subprocess.check_output(command, shell=True) import xml.etree.ElementTree as ET tree = ET.ElementTree(ET.fromstring(output)) accuracy = float( tree.getroot().find("Dataset").find("Row").find("accuracy").text) return accuracy