def gen_parameters(nodes, conf): global prime prime = gen_prime(nodes) gen_candidate(nodes) global candidate candidate = sorted(candidate) can = [] for i in range(10): conf = dict() conf["nodes"] = nodes k = random.randint(0, len(candidate) - 1) conf["range"] = candidate[k] conf["gen_tasks"] = nodes / conf["range"] k = random.randint(0, len(candidate) - 1) conf["drange"] = candidate[k] conf["stat_tasks"] = nodes / conf["drange"] can.append(conf) feature_map = dict() # Load feature map try: feature_map_input = open(data_io.feature_map(), "r") for line in feature_map_input: feature_map[line.split("|")[0]] = int(line.split("|")[1]) feature_map_input.close() except Exception, e: pass
def make_string(label, x): feature_map = dict() # Load feature map try: feature_map_input = open(data_io.feature_map(), "r") for line in feature_map_input: feature_map[line.split("|")[0]] = int(line.split("|")[1]) feature_map_input.close() except Exception, e: pass
pass maxn = len(feature_map) # Build feature map and rename features tmp = dict() for key in x: if key in feature_map: tmp[feature_map[key]] = x[key] else: feature_map[key] = maxn tmp[feature_map[key]] = x[key] maxn += 1 # Write new feature map try: feature_map_output = open(data_io.feature_map(), "w") for key in feature_map: #print feature_map[key] feature_map_output.write(key) feature_map_output.write("|") feature_map_output.write(str(feature_map[key])) feature_map_output.write("\n") feature_map_output.close() except Exception, e: pass ret = str(label) for key in sorted(tmp.keys()): ret += " " ret += str(key) ret += ":"
maxn = len(feature_map) # Build feature map and rename features tmp = dict() for key in x: if key in feature_map: tmp[feature_map[key]] = x[key] else: feature_map[key] = maxn tmp[feature_map[key]] = x[key] maxn += 1 # Write new feature map try: feature_map_output = open(data_io.feature_map(), "w") for key in feature_map: #print feature_map[key] feature_map_output.write(key) feature_map_output.write("|") feature_map_output.write(str(feature_map[key])) feature_map_output.write("\n") feature_map_output.close() except Exception, e: pass ret = str(label) for key in sorted(tmp.keys()): ret += " " ret += str(key) ret += ":"