Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## prea.recommender.memory
Class UserBased

    java.lang.Object
      prea.recommender.memory.MemoryBasedRecommender
          prea.recommender.memory.UserBased

All Implemented Interfaces:
  Recommender

    public class UserBased

extends MemoryBasedRecommender

The class implementing user-based neighborhood method, predicting by referring to rating matrix for each query.

Since:
  2012. 4. 20
Version:
  1.1
Author:
  Joonseok Lee

Field Summary
`SparseVector` | `userRateAverage` Average of ratings for each user.
`java.lang.String` | `userSimilarityFileName` The name of pre-calculated user similarity file, if it is used.
`boolean` | `userSimilarityPrefetch` Indicating whether the pre-calculated user similarity file is used.

Fields inherited from class prea.recommender.memory.MemoryBasedRecommender
`defaultValue, defaultVote, INVERSE_USER_FREQUENCY, itemCount, maxValue, MEAN_ABS_DIFF, MEAN_SQUARE_DIFF, minValue, neighborSize, PEARSON_CORR, rateMatrix, similarityMethod, SIMPLE_WEIGHTED_AVG, userCount, VECTOR_COS, WEIGHTED_SUM`

Constructor Summary
`UserBased(int uc, int ic, int max, int min, int ns, int sim, boolean df, double dv, SparseVector ura, boolean usp, java.lang.String usfn)` Construct a user-based model with the given data.

Method Summary
`private double` | `estimation(int activeIndex, int targetIndex, int[] ref, int refCount, double[] refWeight, int method)` Estimate a rating based on neighborhood data.
`EvaluationMetrics` | `evaluate(SparseMatrix testMatrix)` Evaluate the designated algorithm with the given test data.
`private SparseVector` | `predict(int userNo, int[] testItemIndex, int k, double[] userSim)` Predict ratings for a given user regarding given set of items, by user-based CF algorithm.

Methods inherited from class prea.recommender.memory.MemoryBasedRecommender
`buildModel, similarity`

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

Field Detail

### userRateAverage

    public SparseVector userRateAverage

  Average of ratings for each user.

### userSimilarityPrefetch

    public boolean userSimilarityPrefetch

  Indicating whether the pre-calculated user similarity file is used.

### userSimilarityFileName

    public java.lang.String userSimilarityFileName

  The name of pre-calculated user similarity file, if it is used.

Constructor Detail

### UserBased

    public UserBased(int uc,
                     int ic,
                     int max,
                     int min,
                     int ns,
                     int sim,
                     boolean df,
                     double dv,
                     SparseVector ura,
                     boolean usp,
                     java.lang.String usfn)

  Construct a user-based model with the given data.

  Parameters:
    `uc` - The number of users in the dataset.
    `ic` - The number of items in the dataset.
    `max` - The maximum rating value in the dataset.
    `min` - The minimum rating value in the dataset.
    `ns` - The neighborhood size.
    `sim` - The method code of similarity measure.
    `df` - Indicator whether to use default values.
    `dv` - Default value if used.
    `ura` - The average of ratings for each user.
    `usp` - Whether the pre-calculated user similarity file is used.
    `usfn` - The name of pre-calculated user similarity file, if it is used.

Method Detail

### evaluate

    public EvaluationMetrics evaluate(SparseMatrix testMatrix)

  Evaluate the designated algorithm with the given test data.

  Parameters:
    `testMatrix` - A rating matrix with test data.
  Returns:
    The result of evaluation, such as MAE, RMSE, and rank-score.

### predict

    private SparseVector predict(int userNo,
                                 int[] testItemIndex,
                                 int k,
                                 double[] userSim)

  Predict ratings for a given user regarding given set of items, by user-based CF algorithm.

  Parameters:
    `userNo` - The user ID.
    `testItemIndex` - The list of items whose ratings will be predicted.
    `k` - The neighborhood size.
    `userSim` - The similarity vector between the target user and all the other users.
  Returns:
    The predicted ratings for each item.

### estimation

    private double estimation(int activeIndex,
                              int targetIndex,
                              int[] ref,
                              int refCount,
                              double[] refWeight,
                              int method)

  Estimate a rating based on neighborhood data.

  Parameters:
    `activeIndex` - The active user index for user-based CF; The item index for item-based CF.
    `targetIndex` - The target item index for user-based CF; The user index for item-based CF.
    `ref` - The indices of neighborhood, which will be used for estimation.
    `refCount` - The number of neighborhood, which will be used for estimation.
    `refWeight` - The weight of each neighborhood.
    `method` - The code of estimation method. It can be one of the following: WEIGHTED_SUM or SIMPLE_WEIGHTED_AVG.
  Returns:
    The estimated rating value.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD