Package org.apache.solr.ltr.model
Class LinearModel
java.lang.Object
org.apache.solr.ltr.model.LTRScoringModel
org.apache.solr.ltr.model.LinearModel
- All Implemented Interfaces:
org.apache.lucene.util.Accountable
A scoring model that computes scores using a dot product. Example models are RankSVM and
Pranking.
Example configuration:
{
"class" : "org.apache.solr.ltr.model.LinearModel",
"name" : "myModelName",
"features" : [
{ "name" : "userTextTitleMatch" },
{ "name" : "originalScore" },
{ "name" : "isBook" }
],
"params" : {
"weights" : {
"userTextTitleMatch" : 1.0,
"originalScore" : 0.5,
"isBook" : 0.1
}
}
}
Training libraries:
Background reading:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Float[]featureToWeight is part of the LTRScoringModel params map and therefore here it does not individually influence the class hashCode, equals, etc.Fields inherited from class org.apache.solr.ltr.model.LTRScoringModel
features, name, normsFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.lucene.search.Explanationexplain(org.apache.lucene.index.LeafReaderContext context, int doc, float finalScore, List<org.apache.lucene.search.Explanation> featureExplanations) Similar to the score() function, except it returns an explanation of how the features were used to calculate the score.floatscore(float[] modelFeatureValuesNormalized) Given a list of normalized values for all features a scoring algorithm cares about, calculate and return a score.voidsetWeights(Object weights) toString()protected voidvalidate()Validate that settings make sense and throwsModelExceptionif they do not make sense.Methods inherited from class org.apache.solr.ltr.model.LTRScoringModel
equals, getAllFeatures, getFeatures, getFeatureStoreName, getInstance, getName, getNormalizerExplanation, getNorms, getParams, hashCode, normalizeFeaturesInPlace, ramBytesUsedMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
Field Details
-
featureToWeight
featureToWeight is part of the LTRScoringModel params map and therefore here it does not individually influence the class hashCode, equals, etc.
-
-
Constructor Details
-
LinearModel
-
-
Method Details
-
setWeights
-
validate
Description copied from class:LTRScoringModelValidate that settings make sense and throwsModelExceptionif they do not make sense.- Overrides:
validatein classLTRScoringModel- Throws:
ModelException
-
score
public float score(float[] modelFeatureValuesNormalized) Description copied from class:LTRScoringModelGiven a list of normalized values for all features a scoring algorithm cares about, calculate and return a score.- Specified by:
scorein classLTRScoringModel- Parameters:
modelFeatureValuesNormalized- List of normalized feature values. Each feature is identified by its id, which is the index in the array- Returns:
- The final score for a document
-
explain
public org.apache.lucene.search.Explanation explain(org.apache.lucene.index.LeafReaderContext context, int doc, float finalScore, List<org.apache.lucene.search.Explanation> featureExplanations) Description copied from class:LTRScoringModelSimilar to the score() function, except it returns an explanation of how the features were used to calculate the score.- Specified by:
explainin classLTRScoringModel- Parameters:
context- Context the document is indoc- Document to explainfinalScore- Original scorefeatureExplanations- Explanations for each feature calculation- Returns:
- Explanation for the scoring of a document
-
toString
- Overrides:
toStringin classLTRScoringModel
-