zhiminy/EvalEng huggingface dataset:
Repository: pykeen/pykeen
Issue: Splitting a triples factory could not find a coverage of all entities and relations
Root cause: Validation Gap

I am getting the error "ValueError: Could not find a coverage of all entities and relation with only 160 triples." once the tf is split!

```python
data = run_query("""
    MATCH (s)-[r]->(t)
    RETURN toString(id(s)) as source, toString(id(t)) AS target, type(r) as type
""")

tf = TriplesFactory.from_labeled_triples(
  data[["source", "type", "target"]].values
)

training, testing, validation = tf.split([.8, .1, .1])`
```

Additionally, tf is **TriplesFactory(num_entities=205, num_relations=6, create_inverse_triples=False, num_triples=200)**
can you please tell me how to fix it?
thanks in advance!

Can you please share the triples that are causing the issue?

      source target                  type
0          4      3            rdf__first
1          5      4             rdf__rest
2          6      5   owl__intersectionOf
3       1233      6  owl__equivalentClass
4         97      7            rdf__first
..       ...    ...                   ...
195  2222876     27   owl__someValuesFrom
196  2227145     27   owl__someValuesFrom
197  2228038     27   owl__someValuesFrom
198  2225495     27   owl__someValuesFrom
199  2227650     27   owl__someValuesFrom

Sorry, but I don't have time to help debug without a full dataset in a structured format. It would also be useful to know the context of where this dataset came from, and how it was made.

thanks for your quick reply.
what does 'a full dataset in a structured format' mean?
I have 200 triples in the form of source, type, target!
for example, in the last triple: 
source: 2227650, type: 27, target: owl__someValuesFrom
can you please tell me if the issue is related to the data?




The data is basically a standard ontology in RDF format that I imported into Neo4j using neosemantics. 

By full dataset, I meant post a TSV file that has 200 rows in it (or 201 if you want to include a header), properly delimited by tabs.

I can see that you ran some kind of Cypher query, but I do not know what data source you used or what `run_query` does under the hood. Often, data issues require knowing something about the data.
Repository: pykeen/pykeen
Issue: Understanding results from the PharmKG8k paper

In your version of the PharmKG8k data you have 7247 entities, 485787 triples and 28 relations, in the PharmKG8k paper it states 7603 entities, 500958 triples and 29 relations. Why are the two datasets different? 

Link to the PharmKG8k paper: https://academic.oup.com/bib/article/22/4/bbaa344/6042240

Hi @pipaluk5, when I made this dataloader I simply load the files as given by the authors here: https://github.com/biomed-AI/PharmKG/tree/master/data/PharmKG-8k 
It's possible that I misreported the numbers in the pykeen docs. If you believe this to be the case then let me know and I will open a PR to correct it. 

Hi @sbonner0, when I count the number of edges in the test, train and valid given by the authors on: https://github.com/biomed-AI/PharmKG/tree/master/data/PharmKG-8k, I get  7262 entities, 500360 triples and 28 relations, so it looks like you may have misreported the numbers in the pykeen docs. But the numbers still don't match what is written in the PharmKG8k paper. Do you know why? 

Also in the PharmKG8k paper they link to another GitHub, than the one you have linked here.  
The paper link to: https://github.com/MindRank-Biotech/PharmKG
But this GitHub does not have any data, so that does not seem like the right GitHub. 

Hi @pipaluk5 if you check the issues section of the repo you listed, you can see an issue that I opening asking for the data and being pointed to the repo: https://github.com/MindRank-Biotech/PharmKG/issues/3 So it is indeed the correct one according to the authors. 

I have no idea why the numbers don't match versus the ones reported in the original publication, I suggest you reach out to the original authors for clarification. 

Thanks for flagging the numbers not being correct even given this dataset though, i'll open a PR to correct them! Thanks again!
Repository: pykeen/pykeen
Issue: Improve documentation on bring your own entity/relation initializers
GitHub labels: documentation

Thank you for a very useful platform for building KGE models. I am working my own KG data set and I would like to initialize entity and relation embeddings with my own initial values for ConvKB and a few other models. I don't see any sample code for it. I see that the initializer functions can be set from one of several internally implemented (such uniform_ etc) but I don't see how I can make them use vectors pre-calculated. I appreciate your help.

Please have a look at https://pykeen.readthedocs.io/en/stable/reference/nn/init.html. We need to improve the high level documentation on this page and make sure its better linked from the tutorial 

This should be the relevant part: https://pykeen.readthedocs.io/en/stable/api/pykeen.nn.init.PretrainedInitializer.html#pykeen.nn.init.PretrainedInitializer

Yes! That worked. Thank you!

Hi
I have my own dataset containing three types of triples:
1. triples as relation between entities e.g.,  234 Located_IN 1254
2.  triples as properties of entities, e.g., 2356 First_Name Sarah
3.  triples as label/type of nodes such as 2356 type Person or 234 type location

Triplefactory treats everything as entity for example all the properties and type values. How can I guide it to differentiate between entity ID and property values?

Thank you
Repository: pykeen/pykeen
Issue: cannot import name 'ScorePack' from 'pykeen.typing'
Root cause: Documentation Deficiency

### Describe the bug

Whenever I am trying to import predict from models as described in the documentation:
https://pykeen.readthedocs.io/en/stable/reference/predict.html#get-prediction-df
using

```python
from pykeen.models import predict
```

I am getting the following error:

```python-traceback
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/anaconda3/lib/python3.8/site-packages/pykeen/models/predict.py", line 21, in <module>
    from ..typing import (
ImportError: cannot import name 'ScorePack' from 'pykeen.typing' (/usr/local/anaconda3/lib/python3.8/site-packages/pykeen/typing.py)
```

### How to reproduce

just import:
```python
from pykeen.models import predict
```

### Environment

Unable to handle parameter in CooccurrenceFilteredModel: base
| Key             | Value                    |
|-----------------|--------------------------|
| OS              | posix                    |
| Platform        | Darwin                   |
| Release         | 22.4.0                   |
| Time            | Tue May  9 20:14:06 2023 |
| Python          | 3.8.5                    |
| PyKEEN          | 1.10.1                   |
| PyKEEN Hash     | UNHASHED                 |
| PyKEEN Branch   |                          |
| PyTorch         | 2.0.1                    |
| CUDA Available? | false                    |
| CUDA Version    | N/A                      |
| cuDNN Version   | N/A                      |


### Additional information

_No response_

### Issue Template Checks

- [X] This is not a feature request (use a different issue template if it is)
- [X] This is not a question (use the [discussions](https://github.com/pykeen/pykeen/discussions/new) forum instead)
- [X] I've read the text explaining why including environment information is important and understand if I omit this information that my issue will be dismissed

Hi @mhmgad ,

the linked page in the documentation described the *old* use as
```python
from pykeen.models import predict
```

while the updated version uses
```python
from pykeen import predict
```

I wonder why the file `pykeen/models/predict.py` exists at all - it is not included in the [1.10.1 release](https://github.com/pykeen/pykeen/tree/v1.10.1/src/pykeen/models) 🤔
Repository: pykeen/pykeen
Issue: PharmKG8k has data leakage
Root cause: Unimplemented Feature Gap

The PharmKG8k dataset that you use, and the one which the people behind the PharmKG8k paper point to have some significant issues.

We think that we have solved these significant issues. The issues consist of data leakage and the split being inductive.
More can be read about it on this GitHub: 
https://github.com/skingi20/improvement_of_PharmKG8k_split
The new split that we propose, which has no data leakage and is transductive, can be found on there as well as proof of the original PharmKG8k split's problems.

I'm a domain expert in biology and chemistry. I'm not very happy with any of the "benchmark" biomedical knowledge graphs we have added in PyKEEN. Despite that, they're included for the convenience of people who aren't so skilled with data acquisition.

I would suggest not investing any time in PharmKG nor its variants since it is one of the worse ones, both in terms of the content included, the questionable semantics, and the fact that its corresponding paper doesn't explain much about how it's made (plus no code available).

If you want to send a PR that adds a warning in the docs for PharmKG that there are issues and people should consider your alternative, then we could consider that, but making more variants of a questionable resource probably won't help pykeen users in the long run.
Repository: pykeen/pykeen
Issue: Hi, I am curious would it be possible to input our own negative samples (like non SL pairs ) in pykeen?
Root cause: Documentation Deficiency

**On which paper(s) is your requested sampler based.**
Please link the original paper where this sampler was proposed as well as other papers that cover this sampler.

**List the original and other existing implementations of this sampler**
Please provide links to the original implementation and an as comprehensive as possible list about other implementations
of this sampler.

**Relevance of this sampler**
Reasons why this sampler should be implemented, e.g. interesting for your research, a specific research topic or
business.

**Ability to help and additional context**
Your background and ability to help with the implementation of the sampler.


Hi @Chun-Pei, this isn't a very informative issue - you didn't appear to choose an appropriate template (or blank issue) not give any meaningful context. This also appears to be a question, so it should go into the discussions board.
Repository: pykeen/pykeen
Issue: Use pathlib.Path instead of str for all internal uses
GitHub labels: enhancement

[pathlib](https://docs.python.org/3/library/pathlib.html#module-pathlib) offers a high-level API for working with paths. It also allows for clearer type annotations than just `str`. This issues proposes to use pathlib wherever possible. For ease-of-use, users should still be able to provide `str` paths.
Repository: pykeen/pykeen
Issue: How to complete entities_to_id using a trained model?
Root cause: Documentation Deficiency

### Describe the bug

```
training = TriplesFactory.from_labeled_triples(training_set)

testing = TriplesFactory.from_labeled_triples(
    testing_set,
    entity_to_id=training.entity_to_id,
    relation_to_id=training.relation_to_id,
)

result = pipeline(
    training=training,
    testing=testing,
    model='TransE',
    epochs=1  # short epochs for testing - you should go higher
)

result.save_to_directory('test')
```
I have obtained a model through the above code, and now I want to get some entity embedding through this model, the first  to do is to convert the entity to id. I read the documentation and it only says that it is implemented by training.entities_to_ids, but this training is obtained by loading the dataset. How can I complete entities_to_ids  only have the model without dataset? (I find  entity_to_id.tsv.gz in the saved file, but don't know how to use  in the documentation.)

### How to reproduce

nothing to say

### Environment

nothing to say

### Additional information

_No response_

### Issue Template Checks

- [X] This is not a feature request (use a different issue template if it is)
- [X] This is not a question (use the [discussions](https://github.com/pykeen/pykeen/discussions/new) forum instead)
- [X] I've read the text explaining why including environment information is important and understand if I omit this information that my issue will be dismissed
Repository: pykeen/pykeen
Issue: Cannot pass custom dataset in the ablation pipeline
Root cause: Validation Gap

### Discussed in https://github.com/pykeen/pykeen/discussions/1283

<div type='discussions-op-text'>

<sup>Originally posted by **MathewKevin** June 15, 2023</sup>
I have csv dataset which contains the triples, I split them into train, test and validation set, then I tried to run the ablation pipeline, here is the code that I used,


```python
data = pd.read_csv("bio_data.csv")
train, validate, test = np.split(data.sample(frac=1, random_state=42), [int(0.6 * len(data)), int(0.8 * len(data))])
train.to_csv("store/mydata/train.csv", index=False)

datasets = [
    {
        "training": "store/mydata/train.csv",
        "validation": "store/mydata/validate.csv",
        "testing": "store/mydata/test.csv",
    }
]

model_to_training_loop_to_training_kwargs = {
    "ComplEx": {
        "lcwa": {
            "num_epochs": 50,
            "use_tqdm_batch": False,
            "random_seed": 42,
        }
    }
}

directory = "store/ablation_res/"
ablation_pipeline(
    directory=directory,
    models=["RotatE"],
    datasets=datasets,
    losses=["BCEAfterSigmoidLoss", "MarginRankingLoss"],
    training_loops=["LCWA"],
    model_to_training_loop_to_training_kwargs=model_to_training_loop_to_training_kwargs,
    optimizers=["Adam"],
    stopper="early",
    stopper_kwargs={
        "frequency": 5,
        "patience": 20,
        "relative_delta": 0.002,
        "metric": "hits@10",
    },
    # Add inverse triples with
    create_inverse_triples=[True, False],
    # # Optuna-related arguments
    n_trials=3,
    metric="hits@10",
    direction="maximize",
    sampler="random",
    pruner="nop",
    best_replicates=2,
)
```
```python-traceback
IndexError: index 1 is out of bounds for axis 1 with size 1.
```

When I pass the data in the array format, it throws `JSON serializable error`. How can I pass the data in the ablation pipeline, can someone help with this, thanks in advance.

Did you find a fix?

This should be fixed by #1374 

https://github.com/pykeen/pykeen/pull/1374 has been merged; until our next release you can [install from source](https://github.com/pykeen/pykeen?tab=readme-ov-file#installation--) to get access to it.
Repository: pykeen/pykeen
Issue: AttributeError: type object 'NormLimitRegularizer' has no attribute 'hpo_default'
Root cause: Validation Gap

### Describe the bug

Running HPO for TransH will fail with the following error:

``
Traceback (most recent call last):
  File "/home/hugo/test_pykeen/transh_hpo.py", line 5, in <module>
    result = hpo_pipeline(
  File "/home/hugo/miniconda3/envs/pykeen/lib/python3.10/site-packages/pykeen/hpo/hpo.py", line 865, in hpo_pipeline
    study.optimize(
  File "/home/hugo/miniconda3/envs/pykeen/lib/python3.10/site-packages/optuna/study/study.py", line 425, in optimize
    _optimize(
  File "/home/hugo/miniconda3/envs/pykeen/lib/python3.10/site-packages/optuna/study/_optimize.py", line 66, in _optimize
    _optimize_sequential(
  File "/home/hugo/miniconda3/envs/pykeen/lib/python3.10/site-packages/optuna/study/_optimize.py", line 163, in _optimize_sequential
    frozen_trial = _run_trial(study, func, catch)
  File "/home/hugo/miniconda3/envs/pykeen/lib/python3.10/site-packages/optuna/study/_optimize.py", line 251, in _run_trial
    raise func_err
  File "/home/hugo/miniconda3/envs/pykeen/lib/python3.10/site-packages/optuna/study/_optimize.py", line 200, in _run_trial
    value_or_values = func(trial)
  File "/home/hugo/miniconda3/envs/pykeen/lib/python3.10/site-packages/pykeen/hpo/hpo.py", line 195, in __call__
    default_kwargs_ranges=self.regularizer.hpo_default,
AttributeError: type object 'NormLimitRegularizer' has no attribute 'hpo_default'
``

### How to reproduce

Run the following


``
from pykeen.hpo import hpo_pipeline

result = hpo_pipeline(
    n_trials=10,
    model="transh",
    dataset="Nations",
)
``

### Environment

| Key             | Value                    |
|-----------------|--------------------------|
| OS              | posix                    |
| Platform        | Linux                    |
| Release         | 5.15.102-1-pve           |
| Time            | Thu Jun 22 14:16:04 2023 |
| Python          | 3.10.9                   |
| PyKEEN          | 1.10.1                   |
| PyKEEN Hash     | UNHASHED                 |
| PyKEEN Branch   |                          |
| PyTorch         | 1.13.1                   |
| CUDA Available? | true                     |
| CUDA Version    | 11.7                     |
| cuDNN Version   | 8500                     |


### Additional information

_No response_

### Issue Template Checks

- [X] This is not a feature request (use a different issue template if it is)
- [X] This is not a question (use the [discussions](https://github.com/pykeen/pykeen/discussions/new) forum instead)
- [X] I've read the text explaining why including environment information is important and understand if I omit this information that my issue will be dismissed

Duplicate of https://github.com/pykeen/pykeen/issues/1273. Please see potential fix in https://github.com/pykeen/pykeen/pull/1277

Thanks @cthoyt for the prompt response.
The fix in branch `fix-transh-hpo-compatability` in does indeed allow the code to run.
Repository: pykeen/pykeen
Issue: GPU Allocation Issues
Root cause: Resource Mishandling

I am training a knowledge graph model using pyKEEN (1.8.0 Version) library and the ComplExLiteral model. The problem is with a file which is 1.3 GB contains general triple outputs and a 10 MB file for the triple output as literals, creating an allocation issue since the graphic card I am using is 24GB big. I tested using a combination of the files and it appears that the file causing the issue is the one with 1.3GB. I run the same code using a 40 MB version of it and it worked fine.
Here is an idea regarding the training parameters and the error:
   
```
def create_embedding_model(
    self,
    kg_training_loop="slcwa",
    kg_neg_sampler="bernoulli",
    kg_batch_size=512,
    kg_number_epochs=1,
):
    self.kg_logger.info("Starting to train the knowledge graph embedding model...")

    self.kg_embedding_model_pipeline = pipeline(
        training=self.triples_literals_factory,
        testing=self.triples_literals_factory,
        model=self.kg_embedding_model,
        training_kwargs=dict(
            num_epochs=kg_number_epochs,
            use_tqdm=True,
            batch_size=kg_batch_size,
        ),
        evaluation_kwargs=dict(
            use_tqdm=True,
            batch_size=kg_batch_size // 4
            if torch.cuda.is_available()
            else kg_batch_size,
        ),
        negative_sampler=kg_neg_sampler,
        training_loop=kg_training_loop,
        random_seed=self.kg_random_seed,
    )

    self.kg_embedding_initialized_model = self.kg_embedding_model_pipeline.model

    return self.kg_embedding_initialized_model
```
Error:

`    OutOfMemoryError: CUDA out of memory. Tried to allocate 193.44 GiB (GPU 0; 22.38 GiB total capacity; 5.43 GiB already allocated; 15.64 GiB free; 6.13 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_A
`
I am using the compute farm of my company and I am a beginner in the machine learning field. 
I am using 
Python 3.7.16
PyKEEN 1.8.0 
tensorflow                   2.11.0
tensorflow-estimator         2.3.0
tensorflow-gpu               2.3.2
and torch 1.13.1

I hope that this is helpful
I know that my hardware capacity is limited but maybe there is another solution to counter the issue since I explicitly want to use PyKEEN and the ComplExLiteral model. If you need anything else from my side tell me
Repository: pykeen/pykeen
Issue: The GCN code will stop while running
Root cause: Resource Mishandling

### Describe the bug

hi,
I used wn18rr to train the RGCN model, but it stopped running like this:
![image](https://github.com/pykeen/pykeen/assets/45581281/178291c1-9314-4022-abbc-4331d288301e)
The data is still in memory, but the computation has stopped and no errors have been reported.

### How to reproduce

this my code:
```
dataset=WN18RR()
os.environ["CUDA_VISIBLE_DEVICES"] = '2,3'
pipeline_result = pipeline(
    dataset=dataset,
    model="RGCN",
    model_kwargs=dict(
        decomposition='bases',
        decomposition_kwargs=dict(
        num_bases=2,
        ),
        edge_weighting='inverse_in_degree',
        embedding_dim=128,
        interaction='distmult',
        num_layers=1,),
    negative_sampler='basic',
    negative_sampler_kwargs=dict(
        num_negs_per_pos=1,
    ),
    loss='BCEWithLogits',
    loss_kwargs=dict(
         reduction='mean',
     ),
    optimizer='Adam',
    optimizer_kwargs=dict(
        lr=0.01,
    ),
    training_kwargs=dict(
        num_epochs=500,
        sampler='schlichtkrull',
        batch_size=300,
        gradient_clipping_max_norm=1.0
    ),
    training_loop='slcwa',
    use_tqdm=True,
)
pipeline_result.save_to_directory('checkpoint/rgcn')
```

### Environment

pykeen==1.10.1

### Additional information

_No response_

### Issue Template Checks

- [X] This is not a feature request (use a different issue template if it is)
- [X] This is not a question (use the [discussions](https://github.com/pykeen/pykeen/discussions/new) forum instead)
- [X] I've read the text explaining why including environment information is important and understand if I omit this information that my issue will be dismissed
Repository: pykeen/pykeen
Issue: ImportError: cannot import name 'get_tail_prediction_df' from 'pykeen.predict'
Root cause: External Dependency Breakage

### Describe the bug

Just write the import command.
This issue will be generated 
```python
from pykeen.predict import get_tail_prediction_df
```

### How to reproduce

```python
from pykeen.predict import get_tail_prediction_df
```

### Environment

Google Colab GPU Setting

### Additional information

_No response_

### Issue Template Checks

- [X] This is not a feature request (use a different issue template if it is)
- [X] This is not a question (use the [discussions](https://github.com/pykeen/pykeen/discussions/new) forum instead)
- [X] I've read the text explaining why including environment information is important and understand if I omit this information that my issue will be dismissed

What version of PyKEEN are you using?

Here is the version
pykeen-1.10.1

@DevDaring , in version 1,9, the API (of the prediction methods) was changed. There is a migration guide available at https://pykeen.readthedocs.io/en/stable/reference/predict.html#migration-guide