How to use the hyperactive.memory.util.get_model_id function in hyperactive

To help you get started, we’ve selected a few hyperactive examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SimonBlanke / Hyperactive / hyperactive / memory / memory_io.py View on Github external
def __init__(self, _space_, _main_args_, _cand_):
        self._space_ = _space_
        self._main_args_ = _main_args_

        self.meta_data_name = get_meta_data_name(_main_args_.X, _main_args_.y)
        self.score_col_name = "_score_"

        model_id = get_model_id(_cand_.func_)
        self.datetime = get_datetime()

        self.meta_path = get_meta_path()
        self.model_path = self.meta_path + get_model_path(model_id)
        self.date_path = self.model_path + get_date_path(self.datetime)

        self.dataset_info_path = self.model_path + "dataset_info/"

        if not os.path.exists(self.date_path):
            os.makedirs(self.date_path, exist_ok=True)

        self.hash2obj = _hash2obj(_space_.search_space, self.model_path)
github SimonBlanke / Hyperactive / hyperactive / memory / memory_helper.py View on Github external
def split_model_IDs(model1, model2):
    # TODO: do checks if search space has same dim

    with open(meta_path + "model_connections.json") as f:
        data = json.load(f)

    model1_hash = get_model_id(model1)
    model2_hash = get_model_id(model2)

    if model1_hash in data:
        key_model = model1_hash
        value_model = model2_hash
        data = _split_key_value(data, key_model, value_model)
    else:
        print("IDs of models are not connected")

    if model2_hash in data:
        key_model = model2_hash
        value_model = model1_hash
        data = _split_key_value(data, key_model, value_model)
    else:
        print("IDs of models are not connected")

    with open(meta_path + "model_connections.json", "w") as f:
github SimonBlanke / Hyperactive / hyperactive / memory / memory_helper.py View on Github external
def _get_file_path(model, X, y):
    func_path_ = "model_id:" + get_model_id(model) + "/"
    func_path = meta_path + func_path_

    feature_hash = get_hash(X)
    label_hash = get_hash(y)

    return func_path + (feature_hash + "_" + label_hash + "_.csv")
github SimonBlanke / Hyperactive / hyperactive / memory / memory_helper.py View on Github external
def split_model_IDs(model1, model2):
    # TODO: do checks if search space has same dim

    with open(meta_path + "model_connections.json") as f:
        data = json.load(f)

    model1_hash = get_model_id(model1)
    model2_hash = get_model_id(model2)

    if model1_hash in data:
        key_model = model1_hash
        value_model = model2_hash
        data = _split_key_value(data, key_model, value_model)
    else:
        print("IDs of models are not connected")

    if model2_hash in data:
        key_model = model2_hash
        value_model = model1_hash
        data = _split_key_value(data, key_model, value_model)
    else:
        print("IDs of models are not connected")
github SimonBlanke / Hyperactive / hyperactive / memory / memory_helper.py View on Github external
def delete_model(model):
    model_hash = get_model_id(model)
    path = meta_path + "model_id:" + str(model_hash)

    if os.path.exists(path) and os.path.isdir(path):
        shutil.rmtree(path)
        print("Model data successfully removed")
    else:
        print("Model data not found in memory")
github SimonBlanke / Hyperactive / hyperactive / memory / memory_load.py View on Github external
self.pos_best = None
        self.score_best = -np.inf

        self.memory_type = _main_args_.memory
        self.meta_data_found = False

        self.con_ids = []

        if not os.path.exists(self.meta_path + "model_connections.json"):
            with open(self.meta_path + "model_connections.json", "w") as f:
                json.dump({}, f, indent=4)

        with open(self.meta_path + "model_connections.json") as f:
            self.model_con = json.load(f)

        model_id = get_model_id(_cand_.func_)
        if model_id in self.model_con:
            self._get_id_list(self.model_con[model_id])
        else:
            self.con_ids = [model_id]

        self.con_ids = set(self.con_ids)
github SimonBlanke / Hyperactive / hyperactive / memory / memory_helper.py View on Github external
def connect_model_IDs(model1, model2):
    # do checks if search space has same dim

    with open(meta_path + "model_connections.json") as f:
        data = json.load(f)

    model1_hash = get_model_id(model1)
    model2_hash = get_model_id(model2)

    if model1_hash in data:
        key_model = model1_hash
        value_model = model2_hash
        data = _connect_key2value(data, key_model, value_model)
    else:
        data[model1_hash] = [model2_hash]
        print("IDs successfully connected")

    if model2_hash in data:
        key_model = model2_hash
        value_model = model1_hash
        data = _connect_key2value(data, key_model, value_model)
    else:
        data[model2_hash] = [model1_hash]
        print("IDs successfully connected")
github SimonBlanke / Hyperactive / hyperactive / memory / memory_helper.py View on Github external
def connect_model_IDs(model1, model2):
    # do checks if search space has same dim

    with open(meta_path + "model_connections.json") as f:
        data = json.load(f)

    model1_hash = get_model_id(model1)
    model2_hash = get_model_id(model2)

    if model1_hash in data:
        key_model = model1_hash
        value_model = model2_hash
        data = _connect_key2value(data, key_model, value_model)
    else:
        data[model1_hash] = [model2_hash]
        print("IDs successfully connected")

    if model2_hash in data:
        key_model = model2_hash
        value_model = model1_hash
        data = _connect_key2value(data, key_model, value_model)
    else:
        data[model2_hash] = [model1_hash]