Skip to content

Instantly share code, notes, and snippets.

@lucentcosmos
Forked from sanealytics/recommenderlab-test RSVD
Last active August 29, 2015 14:17

Revisions

  1. @sanealytics sanealytics revised this gist Mar 10, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion recommenderlab-test RSVD
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ data(MovieLense) # Get data

    # Divvy it up
    scheme <- evaluationScheme(MovieLense, method = "split", train = .9,
    k = 1, given = 10, goodRating = 4)
    k = 1, given = 10, goodRating = 4)

    scheme

  2. @sanealytics sanealytics created this gist Mar 10, 2015.
    38 changes: 38 additions & 0 deletions recommenderlab-test RSVD
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    require(recommenderlab) # Install this if you don't have it already
    require(devtools) # Install this if you don't have this already
    # Get additional recommendation algorithms
    install_github("sanealytics", "recommenderlabrats")

    data(MovieLense) # Get data

    # Divvy it up
    scheme <- evaluationScheme(MovieLense, method = "split", train = .9,
    k = 1, given = 10, goodRating = 4)

    scheme

    # register recommender
    recommenderRegistry$set_entry(
    method="RSVD", dataType = "realRatingMatrix", fun=REAL_RSVD,
    description="Recommender based on Low Rank Matrix Factorization (real data).")

    # Some algorithms to test against
    algorithms <- list(
    "random items" = list(name="RANDOM", param=list(normalize = "Z-score")),
    "popular items" = list(name="POPULAR", param=list(normalize = "Z-score")),
    "user-based CF" = list(name="UBCF", param=list(normalize = "Z-score",
    method="Cosine",
    nn=50, minRating=3)),
    "Matrix Factorization" = list(name="RSVD", param=list(categories = 10,
    lambda = 10,
    maxit = 100))
    )

    # run algorithms, predict next n movies
    results <- evaluate(scheme, algorithms, n=c(1, 3, 5, 10, 15, 20))

    # Draw ROC curve
    plot(results, annotate = 1:4, legend="topleft")

    # See precision / recall
    plot(results, "prec/rec", annotate=3)