Accenture / AmpliGraph

Python library for Representation Learning on Knowledge Graphs https://docs.ampligraph.org
Apache License 2.0
2.14k stars 251 forks source link

RandomBaseline does not return an array of shape [n,2] when evaluating performance using default protocol #134

Closed dogatekin closed 5 years ago

dogatekin commented 5 years ago

Description

RandomBaseline does not return an array of shape [n,2] when running evaluate_performance with use_default_protocol=True.

Actual Behavior

RandomBaseline returns a 1-d array of length n when running evaluate_performance with use_default_protocol=True.

Expected Behavior

RandomBaseline should, like other models, return a 2-d array of shape [n,2] when running evaluate_performance with use_default_protocol=True.

Steps to Reproduce

import numpy as np
from ampligraph.datasets import load_wn18rr
from ampligraph.latent_features import RandomBaseline, DistMult
from ampligraph.evaluation import evaluate_performance

X = load_wn18rr()

model = RandomBaseline()
model.fit(X['train'])
print(evaluate_performance(X['test'][:5], model).shape)  # Returns (5,)

model = DistMult(epochs=0)
model.fit(X['train'])
print(evaluate_performance(X['test'][:5], model).shape)  # Returns (5, 2)

Source

The get_ranks function of RandomBaseline is different from that of the other models, it returns one rank for each test triple regardless of evaluation protocol.

tabacof commented 5 years ago

Solved by #140.