<jupyter_start><jupyter_text>Check which hyper-parameters are required by TransE:<jupyter_code>TransE.hyper_params<jupyter_output><empty_output><jupyter_text>Define output directory:<jupyter_code>output_directory = os.path.join(
    os.path.expanduser('~'), 
    'Desktop', 
    'pykeen_test'
)<jupyter_output><empty_output><jupyter_text>Define hyper-parameters inclduing the evaluation information: * Define the hyper-parameter optimization mode: **HPO_mode** * Define for each hyper-parameter a list of values (single valued lists are possible) * Define the number of hyper-parameter optimization iterations: **maximum_number_of_hpo_iters** * Define the path to the test set (**test_set_path**) or define the ratio of the training set that should be used as test set (**test_set_ratio**) * Define whether you want to compute the metrics (mean rank and hits@k) in raw or in a filtered setting: **filter_negative_triples**<jupyter_code>config = dict(
    training_set_path           = '../../tests/resources/data/rdf.nt',
    test_set_path               = '../../tests/resources/data/rdf.nt', # Just for illustration, we use the training set also as test set
    execution_mode              = 'HPO_mode', # Define hyper-parameter optimization mode
    random_seed                 = 0,
    kg_embedding_model_name     = 'TransE',
    embedding_dim               = [10,20,50,100],
    scoring_function            = [1,2],  
    normalization_of_entities   = [2],  # corresponds to L2
    margin_loss                 = [1,2,3,4,5,6,7,8,9,10],
    learning_rate               = [0.1,0.01,0.001],
    num_epochs                  = [50,100],  
    batch_size                  = [32],
    filter_negative_triples     = True,
    maximum_number_of_hpo_iters = 50, # Define the number HPO iterations
    preferred_device            = 'cpu'
)<jupyter_output><empty_output><jupyter_text>Train and evaluate TransE:<jupyter_code>results = pykeen.run(
    config=config,
    output_directory=output_directory,
)<jupyter_output>HPO Iteration:   0%|          | 0/50 [00:00<?, ?it/s]/Users/mehdi/virtual_envs/pykeen_python_3_7/lib/python3.7/site-packages/torch/nn/functional.py:52: UserWarning: size_average and reduce args will be deprecated, please use reduction='elementwise_mean' instead.
  warnings.warn(warning.format(ret))

Training epoch:   0%|          | 0/50 [00:00<?, ?it/s][A
Training epoch:  22%|██▏       | 11/50 [00:00<00:00, 109.15it/s][A
Training epoch:  54%|█████▍    | 27/50 [00:00<00:00, 119.47it/s][A
Training epoch:  76%|███████▌  | 38/50 [00:00<00:00, 113.64it/s][A
Training epoch:  92%|█████████▏| 46/50 [00:00<00:00, 98.19it/s] [A
                                                               [AINFO:pykeen.utilities.evaluation_utils.metrics_computations:Evaluation took 0.10s seconds
HPO Iteration:   2%|▏         | 1/50 [00:00<00:30,  1.62it/s]
Training epoch:   0%|          | 0/100 [00:00<?, ?it/s][A
Training epoch:  10%|█         | 10/100 [00:00<00:00, 98.34it/s][A
Training epoch:  26%|██▌[...]<jupyter_text>Check result entries:<jupyter_code>results.results.keys()<jupyter_output><empty_output><jupyter_text>Get the model configuration that lead to best results:<jupyter_code>results.results['final_configuration']<jupyter_output><empty_output><jupyter_text>Access trained model:<jupyter_code>results.results['trained_model']<jupyter_output><empty_output><jupyter_text>Visualize loss values:<jupyter_code>losses = results.results['losses']
epochs = np.arange(len(losses))
plt.title(r'Loss Per Epoch')
plt.xlabel('epoch')
plt.ylabel('loss')
plt.plot(epochs, losses)
plt.show()<jupyter_output><empty_output><jupyter_text>Get evaluation results: * Mean rank * Hits@k, k $\in$ {1,3,5,10}<jupyter_code>results.results['eval_summary']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1379857256145916, 'fraction_numerical': 0.051017710811525244, 'mean_word_length': 3.8637532133676094, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '161794', 'license': 'MIT', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1312, 'n_words': 259, 'path': 'notebooks/hyper_parameter_optimization/HPO Mode TransE on RDF.ipynb', 'repo_name': 'Nudin/PyKEEN', 'size': '3783'}