Created
August 5, 2013 11:09
-
-
Save seyna/6155138 to your computer and use it in GitHub Desktop.
Using Myrrix in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages('Myrrix') | |
install.packages("devtools") | |
install.packages("rJava") | |
install.packages("ffbase") | |
library(devtools) | |
install_github("Myrrix-R-interface", "jwijffels", subdir="/Myrrixjars/pkg") | |
install_github("Myrrix-R-interface", "jwijffels", subdir="/Myrrix/pkg") | |
library(Myrrix) | |
## Download example dataset | |
inputfile <- file.path(tempdir(), "audioscrobbler-data.subset.csv.gz") | |
download.file(url="http://dom2bevkhhre1.cloudfront.net/audioscrobbler-data.subset.csv.gz", destfile = inputfile) | |
## Set hyperparameters | |
setMyrrixHyperParameters(params=list(model.iterations.max = 2, model.features=10, model.als.lambda=0.1)) | |
x <- getMyrrixHyperParameters(parameters=c("model.iterations.max","model.features","model.als.lambda")) | |
str(x) | |
## Build a model which will be stored in getwd() and ingest the data file into it | |
recommendationengine <- new("ServerRecommender", localInputDir="/tmp/RtmpeuoEjq/") | |
ingest(recommendationengine, inputfile) | |
await(recommendationengine) | |
## Get all users/items and score alongside the recommendation model | |
items <- getAllItemIDs(recommendationengine) | |
users <- getAllUserIDs(recommendationengine) | |
estimatePreference(recommendationengine, userID=users[1], itemIDs=items[1:20]) | |
estimatePreference(recommendationengine, userID=users[10], itemIDs=items) | |
mostPopularItems(recommendationengine, howMany=10L) | |
recommend(recommendationengine, userID=users[5], howMany=10L) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment