dicee.static_funcs

Functions

create_recipriocal_triples(x)

Add inverse triples into dask dataframe

get_er_vocab(data[, file_path])

get_re_vocab(data[, file_path])

get_ee_vocab(data[, file_path])

timeit(func)

save_pickle(*[, data, file_path])

load_pickle([file_path])

load_term_mapping([file_path])

select_model(args[, is_continual_training, storage_path])

load_model(→ Tuple[object, Tuple[dict, dict]])

Load weights and initialize pytorch module from namespace arguments

load_model_ensemble(...)

Construct Ensemble Of weights and initialize pytorch module from namespace arguments

save_numpy_ndarray(*, data, file_path)

numpy_data_type_changer(→ numpy.ndarray)

Detect most efficient data type for a given triples

save_checkpoint_model(→ None)

Store Pytorch model into disk

store(→ None)

add_noisy_triples(→ pandas.DataFrame)

Add randomly constructed triples

read_or_load_kg(args, cls)

intialize_model(→ Tuple[object, str])

load_json(→ dict)

save_embeddings(→ None)

Save it as CSV if memory allows.

random_prediction(pre_trained_kge)

deploy_triple_prediction(pre_trained_kge, str_subject, ...)

deploy_tail_entity_prediction(pre_trained_kge, ...)

deploy_head_entity_prediction(pre_trained_kge, ...)

deploy_relation_prediction(pre_trained_kge, ...)

vocab_to_parquet(vocab_to_idx, name, ...)

create_experiment_folder([folder_name])

continual_training_setup_executor(→ None)

exponential_function(→ torch.FloatTensor)

load_numpy(→ numpy.ndarray)

evaluate(entity_to_idx, scores, easy_answers, hard_answers)

# @TODO: CD: Renamed this function

download_file(url[, destination_folder])

download_files_from_url(→ None)

download_pretrained_model(→ str)

write_csv_from_model_parallel(path)

Create

from_pretrained_model_write_embeddings_into_csv(→ None)

Module Contents

dicee.static_funcs.create_recipriocal_triples(x)[source]

Add inverse triples into dask dataframe :param x: :return:

dicee.static_funcs.get_er_vocab(data, file_path: str = None)[source]
dicee.static_funcs.get_re_vocab(data, file_path: str = None)[source]
dicee.static_funcs.get_ee_vocab(data, file_path: str = None)[source]
dicee.static_funcs.timeit(func)[source]
dicee.static_funcs.save_pickle(*, data: object = None, file_path=str)[source]
dicee.static_funcs.load_pickle(file_path=str)[source]
dicee.static_funcs.load_term_mapping(file_path=str)[source]
dicee.static_funcs.select_model(args: dict, is_continual_training: bool = None, storage_path: str = None)[source]
dicee.static_funcs.load_model(path_of_experiment_folder: str, model_name='model.pt', verbose=0) Tuple[object, Tuple[dict, dict]][source]

Load weights and initialize pytorch module from namespace arguments

dicee.static_funcs.load_model_ensemble(path_of_experiment_folder: str) Tuple[dicee.models.base_model.BaseKGE, Tuple[pandas.DataFrame, pandas.DataFrame]][source]

Construct Ensemble Of weights and initialize pytorch module from namespace arguments

  1. Detect models under given path

  2. Accumulate parameters of detected models

  3. Normalize parameters

  4. Insert (3) into model.

dicee.static_funcs.save_numpy_ndarray(*, data: numpy.ndarray, file_path: str)[source]
dicee.static_funcs.numpy_data_type_changer(train_set: numpy.ndarray, num: int) numpy.ndarray[source]

Detect most efficient data type for a given triples :param train_set: :param num: :return:

dicee.static_funcs.save_checkpoint_model(model, path: str) None[source]

Store Pytorch model into disk

dicee.static_funcs.store(trained_model, model_name: str = 'model', full_storage_path: str = None, save_embeddings_as_csv=False) None[source]
dicee.static_funcs.add_noisy_triples(train_set: pandas.DataFrame, add_noise_rate: float) pandas.DataFrame[source]

Add randomly constructed triples :param train_set: :param add_noise_rate: :return:

dicee.static_funcs.read_or_load_kg(args, cls)[source]
dicee.static_funcs.intialize_model(args: dict, verbose=0) Tuple[object, str][source]
dicee.static_funcs.load_json(p: str) dict[source]
dicee.static_funcs.save_embeddings(embeddings: numpy.ndarray, indexes, path: str) None[source]

Save it as CSV if memory allows. :param embeddings: :param indexes: :param path: :return:

dicee.static_funcs.random_prediction(pre_trained_kge)[source]
dicee.static_funcs.deploy_triple_prediction(pre_trained_kge, str_subject, str_predicate, str_object)[source]
dicee.static_funcs.deploy_tail_entity_prediction(pre_trained_kge, str_subject, str_predicate, top_k)[source]
dicee.static_funcs.deploy_head_entity_prediction(pre_trained_kge, str_object, str_predicate, top_k)[source]
dicee.static_funcs.deploy_relation_prediction(pre_trained_kge, str_subject, str_object, top_k)[source]
dicee.static_funcs.vocab_to_parquet(vocab_to_idx, name, path_for_serialization, print_into)[source]
dicee.static_funcs.create_experiment_folder(folder_name='Experiments')[source]
dicee.static_funcs.continual_training_setup_executor(executor) None[source]
dicee.static_funcs.exponential_function(x: numpy.ndarray, lam: float, ascending_order=True) torch.FloatTensor[source]
dicee.static_funcs.load_numpy(path) numpy.ndarray[source]
dicee.static_funcs.evaluate(entity_to_idx, scores, easy_answers, hard_answers)[source]

# @TODO: CD: Renamed this function Evaluate multi hop query answering on different query types

dicee.static_funcs.download_file(url, destination_folder='.')[source]
dicee.static_funcs.download_files_from_url(base_url: str, destination_folder='.') None[source]
Parameters:
dicee.static_funcs.download_pretrained_model(url: str) str[source]
dicee.static_funcs.write_csv_from_model_parallel(path: str)[source]

Create

dicee.static_funcs.from_pretrained_model_write_embeddings_into_csv(path: str) None[source]