Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature in the prediction of heads or tails #923

Open
ahmedibatta opened this issue May 15, 2022 · 8 comments
Open

New feature in the prediction of heads or tails #923

ahmedibatta opened this issue May 15, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@ahmedibatta
Copy link

ahmedibatta commented May 15, 2022

Is your feature request related to a problem? Please describe.
Suggestion

Describe the solution you'd like

I used PyKEEN and I think it may be good to add a new argument to the two function get_tail_prediction_df() and get_head_prediction_df() to just produce the new entities with heads or tails with the new relation, for example, if I ask about tails increases by X and not in the training or testing get_tail_prediction_df (result.model, X, 'increases', remove_known=True , triples_factory=result.training) but I will get some entities that already have another relation with X than increases.

Describe alternatives you've considered
Add an option to the function to find the new entities that have specific relation with head or tail and at the same time do not have any relation with this head/tail in the KG.

Additional context
Add any other context or screenshots about the feature request here.

@ahmedibatta ahmedibatta added the enhancement New feature or request label May 15, 2022
@mberr
Copy link
Member

mberr commented May 16, 2022

For my understanding: Let's assume there is another training triple (X, contains, Y), then you want to filter out Y from the predictions of (X, increases, ?)?

@ahmedibatta
Copy link
Author

For my understanding: Let's assume there is another training triple (X, contains, Y), then you want to filter out Y from the predictions of (X, increases, ?)?

Yes , exactly

@mberr
Copy link
Member

mberr commented May 16, 2022

Okay, I think this is a rather unusual use case for KG link prediction, since KG allow having more than one statement about a pair of entities.

However, since the output of the predict_* functions is a pandas dataframe, you can easily remove the unwanted triples, e.g., using https://stackoverflow.com/a/40209800

@ahmedibatta
Copy link
Author

Sure , I did it already, but I think it may be helpful to add it to Pykeen because I thought it is more meaningful.

Furthermore , I used this point after that to implement another function to predict all prediction related to just one entity with all relations instead of the function (get_all_prediction_df) which takes high memory for entities with all relations.

@mberr
Copy link
Member

mberr commented May 16, 2022

Furthermore , I used this point after that to implement another function to predict all prediction related to just one entity with all relations instead of the function (get_all_prediction_df) which takes high memory for entities with all relations.

So here you were looking to predict (e, ?, ?), or at least the top-k scored triples?

@ahmedibatta
Copy link
Author

ahmedibatta commented May 16, 2022

Furthermore , I used this point after that to implement another function to predict all prediction related to just one entity with all relations instead of the function (get_all_prediction_df) which takes high memory for entities with all relations.

So here you were looking to predict (e, ?, ?), or at least the top-k scored triples?

Yes , but in both cases head or tail (e, ? , ?) and (?,? , e)

@mberr
Copy link
Member

mberr commented May 16, 2022

It might also be possible to adapt the utility function

@torch.inference_mode()
def _consume_scores(
model: Model, *consumers: _ScoreConsumer, batch_size: int = 1, mode: Optional[InductiveMode]
) -> None:

to only loop over those triples you are interested in, and write a appropriate score consumer here.

@ahmedibatta
Copy link
Author

May I can try this also, but I implemented it separately to find over all relations and over all entities with a specific entity and then choose for each predicted entity the relation with the highest score and then sort them All.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants