public abstract class WrapperModel extends AdapterModel
This model loads a model from an external resource during the initialization.
The way of fetching the wrapped model is depended on
the implementation of fetchModelMap().
This model doesn't hold the actual parameters of the wrapped model, thus it can manage large models which are difficult to upload to ZooKeeper.
Example configuration:
{
"class": "...",
"name": "myModelName",
"params": {
...
}
}
NOTE: no "features" are configured in the wrapper model because the wrapped model's features will be used instead. Also note that if a "store" is configured for the wrapper model then it must match the "store" of the wrapped model.
| Modifier and Type | Field and Description |
|---|---|
protected LTRScoringModel |
model |
solrResourceLoaderfeatures, name, normsNULL_ACCOUNTABLE| Constructor and Description |
|---|
WrapperModel(String name,
List<Feature> features,
List<Normalizer> norms,
String featureStoreName,
List<Feature> allFeatures,
Map<String,Object> params) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
Explanation |
explain(LeafReaderContext context,
int doc,
float finalScore,
List<Explanation> featureExplanations)
Similar to the score() function, except it returns an explanation of how
the features were used to calculate the score.
|
abstract Map<String,Object> |
fetchModelMap() |
Collection<Feature> |
getAllFeatures() |
List<Feature> |
getFeatures() |
Explanation |
getNormalizerExplanation(Explanation e,
int idx) |
List<Normalizer> |
getNorms() |
int |
hashCode() |
void |
normalizeFeaturesInPlace(float[] modelFeatureValues)
Goes through all the stored feature values, and calculates the normalized
values for all the features that will be used for scoring.
|
long |
ramBytesUsed() |
float |
score(float[] modelFeatureValuesNormalized)
Given a list of normalized values for all features a scoring algorithm
cares about, calculate and return a score.
|
String |
toString() |
void |
updateModel(LTRScoringModel model) |
protected void |
validate()
Validate that settings make sense and throws
ModelException if they do not make sense. |
initgetFeatureStoreName, getInstance, getName, getParamsclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetChildResourcesprotected LTRScoringModel model
public int hashCode()
hashCode in class LTRScoringModelpublic boolean equals(Object obj)
equals in class LTRScoringModelprotected void validate()
throws ModelException
LTRScoringModelModelException if they do not make sense.validate in class LTRScoringModelModelExceptionpublic void updateModel(LTRScoringModel model)
public abstract Map<String,Object> fetchModelMap() throws ModelException
ModelExceptionpublic List<Normalizer> getNorms()
getNorms in class LTRScoringModelpublic List<Feature> getFeatures()
getFeatures in class LTRScoringModelpublic Collection<Feature> getAllFeatures()
getAllFeatures in class LTRScoringModelpublic long ramBytesUsed()
ramBytesUsed in interface AccountableramBytesUsed in class LTRScoringModelpublic float score(float[] modelFeatureValuesNormalized)
LTRScoringModelscore in class LTRScoringModelmodelFeatureValuesNormalized - List of normalized feature values. Each feature is identified by
its id, which is the index in the arraypublic Explanation explain(LeafReaderContext context, int doc, float finalScore, List<Explanation> featureExplanations)
LTRScoringModelexplain in class LTRScoringModelcontext - Context the document is indoc - Document to explainfinalScore - Original scorefeatureExplanations - Explanations for each feature calculationpublic void normalizeFeaturesInPlace(float[] modelFeatureValues)
LTRScoringModelnormalizeFeaturesInPlace in class LTRScoringModelpublic Explanation getNormalizerExplanation(Explanation e, int idx)
getNormalizerExplanation in class LTRScoringModelpublic String toString()
toString in class LTRScoringModelCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.