public abstract class LTRScoringModel extends Object implements Accountable
A scoring model consists of
Feature) and
Normalizer) plus
Example configuration (snippet):
{
"class" : "...",
"name" : "myModelName",
"features" : [
{
"name" : "isBook"
},
{
"name" : "originalScore",
"norm": {
"class" : "org.apache.solr.ltr.norm.StandardNormalizer",
"params" : { "avg":"100", "std":"10" }
}
},
{
"name" : "price",
"norm": {
"class" : "org.apache.solr.ltr.norm.MinMaxNormalizer",
"params" : { "min":"0", "max":"1000" }
}
}
],
"params" : {
...
}
}
LTRScoringModel is an abstract class and concrete classes must
implement the score(float[]) and
explain(LeafReaderContext, int, float, List) methods.
| Modifier and Type | Field and Description |
|---|---|
protected List<Feature> |
features |
protected String |
name |
protected List<Normalizer> |
norms |
| Constructor and Description |
|---|
LTRScoringModel(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) |
abstract 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.
|
Collection<Feature> |
getAllFeatures() |
List<Feature> |
getFeatures() |
String |
getFeatureStoreName() |
static LTRScoringModel |
getInstance(SolrResourceLoader solrResourceLoader,
String className,
String name,
List<Feature> features,
List<Normalizer> norms,
String featureStoreName,
List<Feature> allFeatures,
Map<String,Object> params) |
String |
getName() |
Explanation |
getNormalizerExplanation(Explanation e,
int idx) |
List<Normalizer> |
getNorms() |
Map<String,Object> |
getParams() |
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() |
abstract 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() |
protected void |
validate()
Validate that settings make sense and throws
ModelException if they do not make sense. |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetChildResourcesprotected final String name
protected final List<Normalizer> norms
public static LTRScoringModel getInstance(SolrResourceLoader solrResourceLoader, String className, String name, List<Feature> features, List<Normalizer> norms, String featureStoreName, List<Feature> allFeatures, Map<String,Object> params) throws ModelException
ModelExceptionprotected void validate()
throws ModelException
ModelException if they do not make sense.ModelExceptionpublic List<Normalizer> getNorms()
public String getName()
public long ramBytesUsed()
ramBytesUsed in interface Accountablepublic Collection<Feature> getAllFeatures()
public String getFeatureStoreName()
public abstract float score(float[] modelFeatureValuesNormalized)
modelFeatureValuesNormalized - List of normalized feature values. Each feature is identified by
its id, which is the index in the arraypublic abstract Explanation explain(LeafReaderContext context, int doc, float finalScore, List<Explanation> featureExplanations)
context - Context the document is indoc - Document to explainfinalScore - Original scorefeatureExplanations - Explanations for each feature calculationpublic void normalizeFeaturesInPlace(float[] modelFeatureValues)
public Explanation getNormalizerExplanation(Explanation e, int idx)
Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.