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

public class LinearModel extends LTRScoringModel
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 Details

    • featureToWeight

      protected Float[] featureToWeight
      featureToWeight is part of the LTRScoringModel params map and therefore here it does not individually influence the class hashCode, equals, etc.
  • Constructor Details

  • Method Details

    • setWeights

      public void setWeights(Object weights)
    • validate

      protected void validate() throws ModelException
      Description copied from class: LTRScoringModel
      Validate that settings make sense and throws ModelException if they do not make sense.
      Overrides:
      validate in class LTRScoringModel
      Throws:
      ModelException
    • score

      public float score(float[] modelFeatureValuesNormalized)
      Description copied from class: LTRScoringModel
      Given a list of normalized values for all features a scoring algorithm cares about, calculate and return a score.
      Specified by:
      score in class LTRScoringModel
      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: LTRScoringModel
      Similar to the score() function, except it returns an explanation of how the features were used to calculate the score.
      Specified by:
      explain in class LTRScoringModel
      Parameters:
      context - Context the document is in
      doc - Document to explain
      finalScore - Original score
      featureExplanations - Explanations for each feature calculation
      Returns:
      Explanation for the scoring of a document
    • toString

      public String toString()
      Overrides:
      toString in class LTRScoringModel