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 |
solrResourceLoader
features, name, norms
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. |
init
getFeatureStoreName, getInstance, getName, getParams
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getChildResources
protected LTRScoringModel model
public int hashCode()
hashCode
in class LTRScoringModel
public boolean equals(Object obj)
equals
in class LTRScoringModel
protected void validate() throws ModelException
LTRScoringModel
ModelException
if they do not make sense.validate
in class LTRScoringModel
ModelException
public void updateModel(LTRScoringModel model)
public abstract Map<String,Object> fetchModelMap() throws ModelException
ModelException
public List<Normalizer> getNorms()
getNorms
in class LTRScoringModel
public List<Feature> getFeatures()
getFeatures
in class LTRScoringModel
public Collection<Feature> getAllFeatures()
getAllFeatures
in class LTRScoringModel
public long ramBytesUsed()
ramBytesUsed
in interface Accountable
ramBytesUsed
in class LTRScoringModel
public float score(float[] modelFeatureValuesNormalized)
LTRScoringModel
score
in class LTRScoringModel
modelFeatureValuesNormalized
- 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)
LTRScoringModel
explain
in class LTRScoringModel
context
- Context the document is indoc
- Document to explainfinalScore
- Original scorefeatureExplanations
- Explanations for each feature calculationpublic void normalizeFeaturesInPlace(float[] modelFeatureValues)
LTRScoringModel
normalizeFeaturesInPlace
in class LTRScoringModel
public Explanation getNormalizerExplanation(Explanation e, int idx)
getNormalizerExplanation
in class LTRScoringModel
public String toString()
toString
in class LTRScoringModel
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.