-
Notifications
You must be signed in to change notification settings - Fork 37
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
#109: Make maximum and default grades configurable. #111
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8fcd697
#109: Updates to ERR implementation:
9ec19ad
#109: Updates to NDCG@K implementation:
7a4636c
#109: Add parameters to ERR javadoc.
ef1bc11
#109: Add k, grade parameters to RR constructor; use floating point v…
0784fdc
#109: Changes to allow default max grade, default missing grade to be…
3a0d2c6
#109: Javadoc, tidying, reducing code repetition.
bcdfa48
#109: Add configurable name parameters to ERR, NDCG, RR.
0039da9
#109: Fix field names in Maven evaluation plugins.
11f6308
#109: Minor formatting fixes.
11f295b
#109: Standardise parameter names to camelCase versions for ERR, NDCG…
5557459
#109: Instantiate MetricClassConfigurationManager immediately on star…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
83 changes: 83 additions & 0 deletions
83
rre-core/src/main/java/io/sease/rre/core/domain/metrics/MetricClassConfigurationManager.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,83 @@ | ||
package io.sease.rre.core.domain.metrics; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
/** | ||
* Singleton utility class for instantiating the metric class manager, | ||
* and managing metric configuration details. | ||
* | ||
* @author Matt Pearce ([email protected]) | ||
*/ | ||
public class MetricClassConfigurationManager { | ||
|
||
private static MetricClassConfigurationManager INSTANCE = new MetricClassConfigurationManager(); | ||
|
||
private BigDecimal defaultMaximumGrade = BigDecimal.valueOf(3); | ||
private BigDecimal defaultMissingGrade = BigDecimal.valueOf(2); | ||
|
||
public static MetricClassConfigurationManager getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
/** | ||
* Build the appropriate {@link MetricClassManager} for the metric | ||
* configuration passed. | ||
* | ||
* @param metrics the simple metric configurations - a list of metric classes. | ||
* @param parameterizedMetrics the parameterized metric configuration, consisting | ||
* of class names and additional configuration. | ||
* @return a {@link MetricClassManager} that can instantiate all of the | ||
* configured metrics. | ||
*/ | ||
@SuppressWarnings("rawtypes") | ||
public MetricClassManager buildMetricClassManager(final Collection<String> metrics, final Map<String, Map> parameterizedMetrics) { | ||
final MetricClassManager metricClassManager; | ||
if (parameterizedMetrics == null || parameterizedMetrics.isEmpty()) { | ||
metricClassManager = new SimpleMetricClassManager(metrics); | ||
} else { | ||
metricClassManager = new ParameterizedMetricClassManager(metrics, parameterizedMetrics); | ||
} | ||
return metricClassManager; | ||
} | ||
|
||
/** | ||
* @return the default maximum grade to use when evaluating metrics. May be | ||
* overridden in parameterized metric configuration. | ||
*/ | ||
public BigDecimal getDefaultMaximumGrade() { | ||
return defaultMaximumGrade; | ||
} | ||
|
||
/** | ||
* Set the default maximum grade to use when evaluating metrics. | ||
* | ||
* @param defaultMaximumGrade the grade to use. | ||
* @return the singleton manager instance. | ||
*/ | ||
public MetricClassConfigurationManager setDefaultMaximumGrade(final float defaultMaximumGrade) { | ||
this.defaultMaximumGrade = BigDecimal.valueOf(defaultMaximumGrade); | ||
return this; | ||
} | ||
|
||
/** | ||
* @return the default grade to use when evaluating metrics, and no judgement | ||
* is present for the current document. May be overridden in parameterized | ||
* metric configuration. | ||
*/ | ||
public BigDecimal getDefaultMissingGrade() { | ||
return defaultMissingGrade; | ||
} | ||
|
||
/** | ||
* Set the default missing judgement grade to use when evaluating metrics. | ||
* | ||
* @param defaultMissingGrade the grade to use. | ||
* @return the singleton manager instance. | ||
*/ | ||
public MetricClassConfigurationManager setDefaultMissingGrade(final float defaultMissingGrade) { | ||
this.defaultMissingGrade = BigDecimal.valueOf(defaultMissingGrade); | ||
return this; | ||
} | ||
} |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The constructor is empty so we could do
private final static MetricClassConfigurationManager INSTANCE = new MetricClassConfigurationManager();
what do you think?
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.
Sure, I've just made that change. My thinking was to not create before it is required, but it is used at the very beginning, and is not a big class either, so it's a sensible change to make.