Skip to contents

Predicts user u's rating of item i. For two items j and i let S_{j,i}(chi) be the set of users who rated both. The average deviation of item i with respect to item j is dev_{j,i} = sum_{u in S_{j,i}} (u_j - u_i) / card(S_{j,i}). Since dev_{j,i} + u_i is itself a prediction of u_j, the SLOPE ONE prediction averages them, P(u)_j = sum_{i in R_j} (dev_{j,i} + u_i) / card(R_j) with R_j the items the user rated other than j that have at least one co-rating user, and the WEIGHTED SLOPE ONE prediction weights each term by how many users support it, P_wS1(u)_j = sum (dev_{j,i} + u_i) c_{j,i} / sum c_{j,i} over the items the user rated other than j, where c_{j,i} is card(S_{j,i}(chi)).

Usage

Slope1(R, u, i)

Arguments

R

Users-by-items rating matrix; missing ratings are NA or NaN.

u

Zero-based row index of the user whose rating is predicted.

i

Zero-based column index of the target item.

Value

List with estimate (weighted prediction), weighted_slope_one, slope_one, user_mean, n_pairs, support, fallback, observed, error, n_users, n_items, user, item, method.

Details

Both are returned; estimate is the weighted form, the scheme Lemire & Maclachlan recommend. When no co-rated pair supports the target item the prediction falls back to the user's own mean and fallback is set to 1.

References

Lemire, D. & Maclachlan, A. (2005). Slope one predictors for online rating-based collaborative filtering. Proceedings of the 2005 SIAM International Conference on Data Mining, 471-475. doi:10.1137/1.9781611972757.43

Examples

R <- matrix(c(5, 3, NA, 4, NA, 2, NA, 5, 3), 3, 3, byrow = TRUE)
Slope1(R, u = 0, i = 2)
#> $estimate
#> [1] 2
#> 
#> $weighted_slope_one
#> [1] 2
#> 
#> $slope_one
#> [1] 2
#> 
#> $user_mean
#> [1] 4
#> 
#> $n_pairs
#> [1] 2
#> 
#> $support
#> [1] 2
#> 
#> $fallback
#> [1] 0
#> 
#> $observed
#> [1] NA
#> 
#> $error
#> [1] NA
#> 
#> $n_users
#> [1] 3
#> 
#> $n_items
#> [1] 3
#> 
#> $user
#> [1] 0
#> 
#> $item
#> [1] 2
#> 
#> $method
#> [1] "Weighted Slope One predictor (Lemire & Maclachlan 2005)"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"