Class ConstantModel

java.lang.Object
  extended by ConstantModel

public class ConstantModel
extends java.lang.Object

This is a class implementing three baselines, including constant model, user average, and item average.

Since:
2011. 7. 12
Version:
20110712
Author:
Joonseok Lee

Field Summary
static int ITEM_AVG
          Algorithm Code for Item Average
 int itemCount
          The number of items.
 SparseVector itemRateAverage
          Average of ratings for each item.
 int maxValue
          Maximum value of rating, existing in the dataset.
static int MEDIAN
          Algorithm Code for Constant Model
 int minValue
          Minimum value of rating, existing in the dataset.
static int RANDOM
          Algorithm Code for Random
 int rateCount
          The total number of ratings in the rating matrix.
 SparseMatrix rateMatrix
          Rating matrix for each user (row) and item (column)
 SparseMatrix testMatrix
          Rating matrix for test items.
static int USER_AVG
          Algorithm Code for User Average
 int userCount
          The number of users.
 SparseVector userRateAverage
          Average of ratings for each user.
 
Constructor Summary
ConstantModel(SparseMatrix rm, SparseMatrix tm, SparseVector ura, SparseVector ira, int uc, int ic, int max, int min)
          Construct a constant model with the given data.
 
Method Summary
 EvaluationMetrics evaluate(int method)
          Evaluate the designated algorithm with the given test data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MEDIAN

public static final int MEDIAN
Algorithm Code for Constant Model

See Also:
Constant Field Values

USER_AVG

public static final int USER_AVG
Algorithm Code for User Average

See Also:
Constant Field Values

ITEM_AVG

public static final int ITEM_AVG
Algorithm Code for Item Average

See Also:
Constant Field Values

RANDOM

public static final int RANDOM
Algorithm Code for Random

See Also:
Constant Field Values

rateMatrix

public SparseMatrix rateMatrix
Rating matrix for each user (row) and item (column)


testMatrix

public SparseMatrix testMatrix
Rating matrix for test items. Not allowed to refer during training phase.


userRateAverage

public SparseVector userRateAverage
Average of ratings for each user.


itemRateAverage

public SparseVector itemRateAverage
Average of ratings for each item.


userCount

public int userCount
The number of users.


itemCount

public int itemCount
The number of items.


rateCount

public int rateCount
The total number of ratings in the rating matrix.


maxValue

public int maxValue
Maximum value of rating, existing in the dataset.


minValue

public int minValue
Minimum value of rating, existing in the dataset.

Constructor Detail

ConstantModel

public ConstantModel(SparseMatrix rm,
                     SparseMatrix tm,
                     SparseVector ura,
                     SparseVector ira,
                     int uc,
                     int ic,
                     int max,
                     int min)
Construct a constant model with the given data.

Parameters:
rm - The rating matrix which will be used for training.
tm - The rating matrix which will be used for testing.
ura - The average of ratings for each user.
ira - The average of ratings for each item.
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.
Method Detail

evaluate

public EvaluationMetrics evaluate(int method)
Evaluate the designated algorithm with the given test data.

Parameters:
method - The code of algorithm to be tested. It can have one of the following: MEDIAN, USER_AVG, or ITEM_AVG.
Returns:
The result of evaluation, such as MAE, RMSE, and rank-score.