Repository: pykeen/pykeen
Issue: CoreTriplesFactory.get_most_frequent_relations() not working
Root cause: Validation Gap

### Describe the bug

After trying out loading a (numpy) array of shape (n, 3) I realised that the CoreTriplesFactory cannot:
a) generate splits
b) get_most_frequent_relations 

throwing the following error.

```python-traceback
~/Documents/virtualenvs/bio-blp/lib/python3.8/site-packages/pykeen/triples/triples_factory.py in get_most_frequent_relations(self, n)
    557             raise TypeError("n must be either an integer or a float")
    558 
--> 559         uniq, counts = self.mapped_triples[:, 1].unique(return_counts=True)
    560         top_counts, top_ids = counts.topk(k=n, largest=True)
    561         return set(uniq[top_ids].tolist())

AttributeError: 'numpy.ndarray' object has no attribute 'unique'
```

After spending some time on it, I realised that the problem is that `mapped_triples` cannot be a np.array but **only/strictly** a Tensor. Which is not conveyed in the source doc linked below:

Related link to docs: [[docs]](https://pykeen.readthedocs.io/en/stable/reference/triples.html#pykeen.triples.CoreTriplesFactory)

```
:param mapped_triples: shape: (n, 3)
            A three-column matrix where each row are the head identifier, relation identifier, then tail identifier.
```


I would suggest to:
- Make sure that the source documentation agrees with the rendered version. Something like:
    - :param mapped_triples: shape: (n, 3)
            A three-column _**Tensor**_ where each row are the head identifier, relation identifier, then tail identifier.

Or perhaps to allow CoreTriplesFactory to better handle np.arrays as input by:

- Parse np.array and convert to tensor as soon as it is loaded.
- Throw an error message if the CoreTriplesFactory gets a `np.array` instead of a Tensor 

### How to reproduce

MWE: 

```python
import numpy as np

from pykeen.triples import CoreTriplesFactory

test_triples = np.array([
        [ 15548,      0,  97496],
        [ 72410,      0,  38003],
        [ 89755,      0,  64863],
        [ 77672,      0,  95861],
        [101845,      0,  16285],
        [ 81927,      0,  42651],
        [ 24379,      1, 101310],
        [ 61532,      1,  55533],
        [ 41870,      1,  12293],
        [ 77958,      1,  45418],
        [ 15090,      1,  80033],
        [ 53222,      1,  51502],
        [ 26222,      1,  75007],
        [ 57561,      1,  16921],
        [ 36320,      1,   3573],
        [  7206,      1,  87181],
        [  2170,      1,   2048],
        [ 24826,      1,  90277],
        [ 98015,      1,  88814],
        [ 98903,      1,  97023],
])

unique_entities = 40
unique_relations = 2

test_factory = CoreTriplesFactory(
    mapped_triples=test_triples,
    num_entities=unique_entities,
    num_relations=unique_relations
)
test_factory.get_most_frequent_relations(n=5)
```


### Environment

| Key             | Value                    |
|-----------------|--------------------------|
| OS              | posix                    |
| Platform        | Darwin                   |
| Release         | 21.5.0                   |
| Time            | Fri Jul  8 12:08:06 2022 |
| Python          | 3.8.5                    |
| PyKEEN          | 1.8.2                    |
| PyKEEN Hash     | UNHASHED                 |
| PyKEEN Branch   |                          |
| PyTorch         | 1.12.0                   |
| CUDA Available? | false                    |
| CUDA Version    | N/A                      |
| cuDNN Version   | N/A                      |

### Additional information

I could open a PR and contribute to this :) 

### 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

@DimitrisAlivas thanks for point this out. could you update the MWE to have the right imports and be directly runnable (missing some variable definitions)

How is it looking now @cthoyt ? I added the `num_entities`, `num_relations` that were missing

You should pass a LongTensor to this construct, not a numpy array. Maybe we should be type checking and converting inside here to guard against this. The following works:

```python
import numpy as np
from pykeen.triples import CoreTriplesFactory
import torch

test_triples = torch.from_numpy(np.array([
    [15548, 0, 97496],
    [72410, 0, 38003],
    [89755, 0, 64863],
    [77672, 0, 95861],
    [101845, 0, 16285],
    [81927, 0, 42651],
    [24379, 1, 101310],
    [61532, 1, 55533],
    [41870, 1, 12293],
    [77958, 1, 45418],
    [15090, 1, 80033],
    [53222, 1, 51502],
    [26222, 1, 75007],
    [57561, 1, 16921],
    [36320, 1, 3573],
    [7206, 1, 87181],
    [2170, 1, 2048],
    [24826, 1, 90277],
    [98015, 1, 88814],
    [98903, 1, 97023],
]))

unique_entities = 40
unique_relations = 2

test_factory = CoreTriplesFactory(
    mapped_triples=test_triples,
    num_entities=unique_entities,
    num_relations=unique_relations
)
test_factory.get_most_frequent_relations(n=2)
```


We could think about using [`torch.as_tensor`](https://pytorch.org/docs/stable/generated/torch.as_tensor.html) to normalize the triples passed to `CoreTriplesFactory`

Took a while, but now the update has been merged to `master` 🙂