reco4php icon indicating copy to clipboard operation
reco4php copied to clipboard

PostProcessPhaseExecutor gets wrong post processors

Open rubenvandeven opened this issue 10 years ago • 3 comments

Unfortunately, I'm currently not able to make a pull request, so I will file the issue trough this channel.

In PostProcessPhaseExecutor, on line 46 there is a function call to $recommendationEngine->postProcessors(). However, I believe this should be $recommendationEngine->getPostProcessors():

As in the example scripts, postProcessors() triggers the instantiation of new PostProcessor objects, whereas getPostProcessors() makes sure the objects that were instantiated before are reused.

PS. I found this issue when needing a workaround to trigger only one query to fetch scores for all recommendations at once instead of a query for each recommendation (100ms vs 10sec). If you would have another, more formal, solution to realise this, I would certainly be open for that.

Currently, I gather the recomendation in the object in the buildQuery method -- which has to return an empty query, not to crash subsequent code (again, I'm now not able to alter the reco4php code, might do this later to allow to skip an empty return value in PostProcessPhaseExecutor (l50) ). Then I trigger a query on the first call to postProcess(), the results of which are stored in the postProcessor object for the subsequent calls to postProcess. It works, but it will not win any beauty contest ;-)

rubenvandeven avatar Apr 05 '16 20:04 rubenvandeven

Thanks for the report. You're right about the getPostProcessors() method. I'll make a fix for this.

I'm interested in the use case for the 10s vs 100ms, this seems to be huge and should be considered a bug or a real feature request if this is something that I can improve in a generic way.

Would you mind sharing more info to christophe (at) graphaware dot com if your use case is private.

Thanks a lot !

ikwattro avatar Apr 05 '16 23:04 ikwattro

@rubenvandeven I have created a branch set-post https://github.com/graphaware/reco4php/tree/set-post

Basically it adds a new abstract PostProcessor that will handle a Set of Recommendations.

The example in the tests RewardWellRated demonstrates the logic, it basically allow to use an UNWIND on the ids of the discovered items.

https://github.com/graphaware/reco4php/blob/set-post/tests/Example/PostProcessing/RewardWellRated.php

It needs some testing, polishing and I'll need to make the old post process work again.

ikwattro avatar Apr 06 '16 21:04 ikwattro

@rubenvandeven I will close this issue, the RecommendationSetPostProcessor has been merged in master, I just need to still add some docs.

ikwattro avatar Apr 25 '16 15:04 ikwattro