|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.ai.scorer.AbstractScorerCache
org.hd.d.pg2k.ai.scorer.MiniScorerCacheImpl
public final class MiniScorerCacheImpl
"Lite" implementation to compute (and cache) the score and confidence for exhibits. Used were access to the full data pipeline is not available or too expensive, and where memory and CPU resources are potentially scarce, for example in an applet or JWS app run by a user to donate CPU time.
This caps its use of resources, population size, etc, at smaller levels than a "full" implementation might.
This only handles the most promising sub-set of "real" parameterised Scorers.
| Field Summary | |
|---|---|
(package private) java.util.Map<Name.ExhibitShort,ScoreAndConf> |
calibrationData
Immutable map from short exhibit name to calibration data; never null but may be empty. |
static java.util.Map<java.lang.String,ScorerIF> |
fixedSimpleScorers
The (small) immutable current fixed set of parameterless base Scorer instances. |
static int |
MAX_MINI_SCORER_SCORES_RETAINED
Maximum number of Scorers retained in the population; strictly positive. |
| Fields inherited from class org.hd.d.pg2k.ai.scorer.AbstractScorerCache |
|---|
dataSource, log, population |
| Fields inherited from interface org.hd.d.pg2k.ai.scorer.ScorerCacheIF |
|---|
TRIVIAL |
| Constructor Summary | |
|---|---|
MiniScorerCacheImpl(SimpleExhibitPipelineIF dataSource,
SimpleLoggerIF log,
ScorerPopulation.NewBestCallbackIF callback)
Construct an instance attached to the supplied data source and logger. |
|
| Method Summary | |
|---|---|
ScoreAndConf |
computeCompositeScoreAndConfidence(Name.ExhibitFull exhibitName,
boolean allowStale)
Computes a weighted composite score [-1,+1] and confidence [0,+1] for the specified exhibit with the best available scorers/parameters; never null but may be (0,0). |
ScoreAndConf |
computeScorerWeighting(ScorerIF scorer,
boolean allowStale,
java.lang.String source)
ScoreAndConfidence for the given scorer itself over all exhibit types; never null but may be (0,0) where the scorer is unknown or untested. |
java.util.Map<Name.ExhibitShort,ScoreAndConf> |
extractCalibrationSet(java.lang.String basename,
int maxSamples,
java.lang.Boolean difficult,
boolean allowStale)
Compute exemplar exhibit sub-set to calibrate against; never null but may be empty. |
ScorerIF |
getBaseScorerByName(java.lang.String baseName)
Get base non-parameterised Scorer by name; null if no such base Scorer supported. |
java.util.Set<java.lang.String> |
getBaseScorersWithoutParameters()
Base set of available Scorers' names (no parameters); never null but may be empty. |
ScoreAndConf |
getCachedCompositeScoreAndConfidence(Name.ExhibitFull exhibitName,
boolean allowStale)
Not available. |
java.util.Map<Name.ExhibitShort,ScoreAndConf> |
getCalibrationExhibitsAndScores()
Get the set of exhibits (short names) to calibrate against and their score/confidence values; never null. |
void |
setCalibrationExhibitsAndScores(java.util.Map<Name.ExhibitShort,ScoreAndConf> calibrationData)
Indicate the set of exhibits (short names) to calibrate against and their score/confidence values. |
| Methods inherited from class org.hd.d.pg2k.ai.scorer.AbstractScorerCache |
|---|
canAcceptMoreExternalScorers, computeScorerWeighting, computeUnweightedScoreAndConfidence, destroy, getCurrentScorersWithParameters, getDataSource, getPopulation, getScorerInstance, hasQueuedExternalScorer, offerExternalScorer, poll, size |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.hd.d.pg2k.ai.scorer.ScorerCacheIF |
|---|
canAcceptMoreExternalScorers, computeScorerWeighting, computeUnweightedScoreAndConfidence, destroy, getCurrentScorersWithParameters, getScorerInstance, hasQueuedExternalScorer, offerExternalScorer, poll, size |
| Field Detail |
|---|
public static final int MAX_MINI_SCORER_SCORES_RETAINED
Much more than 1000 may cause out-of-memory difficulties.
volatile java.util.Map<Name.ExhibitShort,ScoreAndConf> calibrationData
Initially empty.
public static final java.util.Map<java.lang.String,ScorerIF> fixedSimpleScorers
These include only the live Scorers that we want end-users to help search for. It is possible that we might allow this to be updated remotely
| Constructor Detail |
|---|
public MiniScorerCacheImpl(SimpleExhibitPipelineIF dataSource,
SimpleLoggerIF log,
ScorerPopulation.NewBestCallbackIF callback)
dataSource - (probably-restricted) live data source; must not be null| Method Detail |
|---|
public void setCalibrationExhibitsAndScores(java.util.Map<Name.ExhibitShort,ScoreAndConf> calibrationData)
This restricts the work that has to be done for calibration (and the data that need be fetched, which may be important for some users), and supplies calibration data that may not be available over a restricted pipeline.
Any exhibit data and metadata required will be fetched from the pipeline.
calibrationData - map from full valid exhibit names to non-null calibration data;
never null, though may be emptypublic java.util.Map<Name.ExhibitShort,ScoreAndConf> getCalibrationExhibitsAndScores()
public ScoreAndConf computeCompositeScoreAndConfidence(Name.ExhibitFull exhibitName,
boolean allowStale)
throws java.io.IOException
computeCompositeScoreAndConfidence in interface ScorerCacheIFexhibitName - valid full exhibit nameallowStale - if true then allow a stale value from cache,
else throw an exception if nothing is currently available
java.io.IOException
public ScoreAndConf getCachedCompositeScoreAndConfidence(Name.ExhibitFull exhibitName,
boolean allowStale)
getCachedCompositeScoreAndConfidence in interface ScorerCacheIFgetCachedCompositeScoreAndConfidence in class AbstractScorerCacheexhibitName - valid full exhibit nameallowStale - if true then allow a stale value from cache,
else throw an exception if nothing is currently available
public java.util.Set<java.lang.String> getBaseScorersWithoutParameters()
getBaseScorersWithoutParameters in interface ScorerCacheIFpublic ScorerIF getBaseScorerByName(java.lang.String baseName)
getBaseScorerByName in interface ScorerCacheIFbaseName - base (no parameters) name of Scorer; must not be null
public java.util.Map<Name.ExhibitShort,ScoreAndConf> extractCalibrationSet(java.lang.String basename,
int maxSamples,
java.lang.Boolean difficult,
boolean allowStale)
extractCalibrationSet in interface ScorerCacheIFbasename - base name of Scorer to extract calibration set for,
or null for a generic all-Scorers calibration setmaxSamples - the maximum number of samples to return; strictly positivedifficult - if TRUE the return the difficult cases that we do not predict well,
if FALSE then return the easy cases that we predict well,
else return a mixure of good, bad, and other random casesallowStale - if true then allow slightly older data for speed and robustness
public ScoreAndConf computeScorerWeighting(ScorerIF scorer,
boolean allowStale,
java.lang.String source)
throws java.io.IOException
Some results will be cached (typically those from the base/current Scorer lists) while other may have to be computed each time, which may be slow.
computeScorerWeighting in interface ScorerCacheIFallowStale - if true then allow a stale or low-confidence value from cache,
else throw an exception if nothing is currently available
and we cannot quickly compute enough points to increase our confidencesource - the name of the mechanism used to generate this Scorer value,
or null if nonescorer - instance of the Scorer; never null
java.io.IOException
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||