-
Notifications
You must be signed in to change notification settings - Fork 65
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
Add harmonic mean combination #238
Add harmonic mean combination #238
Conversation
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
Codecov Report
@@ Coverage Diff @@
## feature/normalization #238 +/- ##
===========================================================
+ Coverage 82.43% 86.02% +3.59%
- Complexity 323 331 +8
===========================================================
Files 26 27 +1
Lines 979 959 -20
Branches 153 150 -3
===========================================================
+ Hits 807 825 +18
+ Misses 108 69 -39
- Partials 64 65 +1
|
...ava/org/opensearch/neuralsearch/processor/combination/AbstractScoreCombinationTechnique.java
Outdated
Show resolved
Hide resolved
...ava/org/opensearch/neuralsearch/processor/combination/AbstractScoreCombinationTechnique.java
Outdated
Show resolved
Hide resolved
@@ -52,7 +38,7 @@ public float combine(final float[] scores) { | |||
for (int indexOfSubQuery = 0; indexOfSubQuery < scores.length; indexOfSubQuery++) { | |||
float score = scores[indexOfSubQuery]; | |||
if (score >= 0.0) { | |||
float weight = getWeightForSubQuery(indexOfSubQuery); | |||
float weight = getWeightForSubQuery(this.weights, indexOfSubQuery); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename local variable name to a different one to avoid future mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
/** | ||
* Base class for score normalization technique | ||
*/ | ||
public abstract class AbstractScoreCombinationTechnique { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not seeing this class as an abstract class, for me its more like having some utility functions. All we are doing here is just doing some utility things. I would rather move this class as a utility class like ScoreCombinationUtility.
Also, the function: getSupportedParams, seems best for an interface and not for an abstract class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Utility class was my second option, my concern was that those methods will be visible. We can put utility class into same package and at least not make methods private. Ack for the method with supported params, it should go to the interface especially if we'll get rid of the abstract class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, exposing those utility methods is not a big concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored abstract class into util class as suggested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make the utility class as package private. I think thats a good thing to do.
CI will fail for some time until compilation errors are fixed in knn, related PR opensearch-project/k-NN#1014 |
src/main/java/org/opensearch/neuralsearch/processor/combination/ScoreCombinationFactory.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
a8ba420
to
3767707
Compare
src/main/java/org/opensearch/neuralsearch/processor/combination/ScoreCombinationUtil.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
1f67b94
into
opensearch-project:feature/normalization
Description
Adding harmonic mean technique (it's a reciprocal of the arithmetic mean of the reciprocals, more details here ). It does support weighted mean similarly to arithmetic mean. Example of pipeline with processor config:
Issues Resolved
#228, part of solution for #126
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.