## org.apache.mahout.cf.taste.impl.recommender.svd
Class SVDRecommender

    java.lang.Object
      org.apache.mahout.cf.taste.impl.recommender.AbstractRecommender
          org.apache.mahout.cf.taste.impl.recommender.svd.SVDRecommender

All Implemented Interfaces:
  Refreshable, Recommender

    public final class SVDRecommender

extends AbstractRecommender

A `Recommender` which uses Single Value Decomposition to find the main features of the data set. Thanks to Simon Funk for the hints in the implementation.

Constructor Summary
`SVDRecommender(DataModel dataModel, CandidateItemsStrategy candidateItemsStrategy, int numFeatures, int initialSteps)`
`SVDRecommender(DataModel dataModel, int numFeatures, int initialSteps)`

Method Summary
`float` `estimatePreference(long userID, long itemID)`
`java.util.List<RecommendedItem>` `recommend(long userID, int howMany, IDRescorer rescorer)`
`void` `refresh(java.util.Collection<Refreshable> alreadyRefreshed)` Triggers "refresh" -- whatever that means -- of the implementation.
`java.lang.String` `toString()`
`void` `train(int steps)`

Methods inherited from class org.apache.mahout.cf.taste.impl.recommender.AbstractRecommender
`getAllOtherItems, getDataModel, getDefaultCandidateItemsStrategy, recommend, removePreference, setPreference`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### SVDRecommender

    public SVDRecommender(DataModel dataModel,
                          CandidateItemsStrategy candidateItemsStrategy,
                          int numFeatures,
                          int initialSteps)
                   throws TasteException

Parameters:
  `numFeatures` - the number of features
  `initialSteps` - number of initial training steps
Throws:
  `TasteException`

### SVDRecommender

    public SVDRecommender(DataModel dataModel,
                          int numFeatures,
                          int initialSteps)
                   throws TasteException

Throws:
  `TasteException`

Method Detail

### train

    public void train(int steps)

### estimatePreference

    public float estimatePreference(long userID,
                                    long itemID)
                             throws TasteException

  Parameters:
    `userID` - user ID whose preference is to be estimated
    `itemID` - item ID to estimate preference for
  Returns:
    an estimated preference if the user has not expressed a preference for the item, or else the user's actual preference for the item. If a preference cannot be estimated, returns `Double.NaN`
  Throws:
    `TasteException` - if an error occurs while accessing the `DataModel`

### recommend

    public java.util.List<RecommendedItem> recommend(long userID,
                                                     int howMany,
                                                     IDRescorer rescorer)
                                              throws TasteException

  Parameters:
    `userID` - user for which recommendations are to be computed
    `howMany` - desired number of recommendations
    `rescorer` - rescoring function to apply before final list of recommendations is determined
  Returns:
    `List` of recommended `RecommendedItem`s, ordered from most strongly recommend to least
  Throws:
    `TasteException` - if an error occurs while accessing the `DataModel`

### refresh

    public void refresh(java.util.Collection<Refreshable> alreadyRefreshed)

  Description copied from interface: `Refreshable`

  Triggers "refresh" -- whatever that means -- of the implementation. The general contract is that any should always leave itself in a consistent, operational state, and that the refresh atomically updates internal state from old to new.

  Parameters:
    `alreadyRefreshed` - s that are known to have already been refreshed as a result of an initial call to a method on some object. This ensure that objects in a refresh dependency graph aren't refreshed twice needlessly.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.