-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: jzonthemtn <[email protected]>
- Loading branch information
1 parent
df5d9a1
commit b9bf8ca
Showing
3 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...valuation-plugin/src/test/java/org/opensearch/eval/metrics/PrecisionSearchMetricTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
package org.opensearch.eval.metrics; | ||
|
||
import org.opensearch.test.OpenSearchTestCase; | ||
|
||
import java.util.List; | ||
|
||
public class PrecisionSearchMetricTest extends OpenSearchTestCase { | ||
|
||
public void testCalculate() { | ||
|
||
final int k = 5; | ||
final double threshold = 1.0; | ||
final List<Double> relevanceScores = List.of(1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 0.0); | ||
|
||
final PrecisionSearchMetric precisionSearchMetric = new PrecisionSearchMetric(k, threshold, relevanceScores); | ||
final double precision = precisionSearchMetric.calculate(); | ||
|
||
assertEquals(1.8, precision, 0.0); | ||
|
||
} | ||
|
||
} |