Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to install reco R package ? #10

Closed
saraswatmks opened this issue Nov 24, 2017 · 21 comments
Closed

How to install reco R package ? #10

saraswatmks opened this issue Nov 24, 2017 · 21 comments

Comments

@saraswatmks
Copy link

Hello

I am unable to install this package. Also, I cannot find any documentation about how to install.
I am getting the following error:

install.packages("reco")
Installing package into ‘/home/manish/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘reco’ is not available (for R version 3.4.1)

Please advise.

Best,
Manish

@dselivanov
Copy link
Owner

Hi. It is not on cran yet. You can use devtools::install_github("dselivanov/reco")

@saraswatmks
Copy link
Author

This works. Thanks.

@mayankgoel4
Copy link

Hi..I tried installing the package using devtools::install_github("dselivanov/reco") and then installed rtools.
Finally used library(reco) to load the package, However still model=ALS$new(rank = 8) is not working and even ?ALS is saying no documentation for function ALS. Any thoughts?

@dselivanov
Copy link
Owner

duplicate #14 #11 - see WRMF class

@mayankgoel4
Copy link

thanks. WRMF function works instead of ALS..

@PalinMemoi
Copy link

devtools::install_github("dselivanov/reco")
Downloading GitHub repo dselivanov/reco@master
from URL https://api.github.com/repos/dselivanov/reco/zipball/master
trying URL 'https://cran.rstudio.com/bin/windows/Rtools/Rtools34.exe'
Content type 'application/x-msdownload' length 108085090 bytes (103.1 MB)
downloaded 103.1 MB

WARNING: Rtools is required to build R packages, but is not currently installed.

Please download and install Rtools 3.4 from http://cran.r-project.org/bin/windows/Rtools/.
Installation failed: Could not find build tools necessary to build rsparse

library(reco)
Error in library(reco) : there is no package called ‘reco’

@dselivanov
Copy link
Owner

@PalinMemoi please install Rtools from CRAN as suggested in error message

@PalinMemoi
Copy link

Plz, help me...I installed Rbuildtools. however, it doesn't work. I tried to install reco again by devtools.... It shows message as below
Downloading GitHub repo dselivanov/reco@master
from URL https://api.github.com/repos/dselivanov/reco/zipball/master
Installing rsparse
Installing 1 package: Rcpp
Installing package into ‘C:/Users/anik/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/Rcpp_0.12.19.zip'
Content type 'application/zip' length 4433824 bytes (4.2 MB)
downloaded 4.2 MB

package ‘Rcpp’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘Rcpp’

The downloaded binary packages are in
C:\Users\anik\AppData\Local\Temp\RtmpEVybHU\downloaded_packages
"C:/PROGRA1/R/R-341.4/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL
"C:/Users/anik/AppData/Local/Temp/RtmpEVybHU/devtools9a82643348d/dselivanov-rsparse-b465c0d"
--library="C:/Users/anik/Documents/R/win-library/3.4" --install-tests

ERROR: dependency 'Rcpp' is not available for package 'rsparse'

  • removing 'C:/Users/anik/Documents/R/win-library/3.4/rsparse'
    In R CMD INSTALL
    Installation failed: Command failed (1)

@zakariaBensmida
Copy link

Hi Dmitry,
i used a 3.3.3 r version with 3.4 rtolls versions and i runed this following code:

install.packages("devtools",type="win.binary")
library(devtools)
devtools::install_github("dselivanov/reco")

(without "win.binary" I was not able to install devtools that"s why i have used it )
so after running i got rsparse installed but reco is not . i have repeated the same process but with 3.5 version for both R and rtools ,it did not worked at all (nothing installed)(ERROR: compilation failed for package 'rsparse)..Since a month and I m trying to solve this problem but I could not install recp package till now.

Could you please help me.

@dselivanov
Copy link
Owner

@zakariaBensmida it is on CRAN now and you can use just install.packages('rsparse')

@zakariaBensmida
Copy link

Hi Dmitry
and then? how to install reco?

@dselivanov
Copy link
Owner

dselivanov commented Apr 25, 2019 via email

@zakariaBensmida
Copy link

Oh my god !!! so you mean i must change some code in your tutorial also? i mean the artist/music recommender system example?

@dselivanov
Copy link
Owner

dselivanov commented Apr 25, 2019 via email

@zakariaBensmida
Copy link

Thank youuuuuuuuuuu veryyyyyyy muchhhhhhhhhhhh

@zakariaBensmida
Copy link

Hi Dmitry,
when i run this:
model$add_scorer(x = X_cv_history_conf, y = X_cv_future, name = "ndcg-10", metric = "ndcg@10")

model$add_scorer(x = X_cv_history_conf, y = X_cv_future, name = "map-10", metric = "map@10")

i got this error :
Error: attempt to apply non-function

@dselivanov
Copy link
Owner

dselivanov commented Apr 25, 2019 via email

@zakariaBensmida
Copy link

Hi dmitry,

when i use the below code i cant find any predictiosn so i can use this code"ap_k(predictions, actual)"
set.seed(1)
library(data.table)
raw_data<-fread("J:/MK-OM-AC/Projekte/Ranking/Daten/usersha1-artmbid-artname-plays.tsv",showProgress=T)

setnames(raw_data, c("user_id", "artist_id", "artist_name", "number_plays"))
head(raw_data)
user_encoding = raw_data[, .(uid = .GRP), keyby = user_id]
print(user_encoding)
item_encoding = raw_data[, .(iid = .GRP, artist_name = artist_name[[1]]), keyby = artist_id]
print(item_encoding)
dt = user_encoding[raw_data, .(artist_id, uid, number_plays), on = .(user_id = user_id)]
dt = item_encoding[dt, .(iid, uid, number_plays), on = .(artist_id = artist_id)]
rm(raw_data)
dt
library(Matrix)
X = sparseMatrix(i = dt$uid, j = dt$iid, x = dt$number_plays,
dimnames = list(user_encoding$user_id, item_encoding$artist_name))
N_CV = 1000L
cv_uid = sample(nrow(user_encoding), N_CV)
X_train = X[-cv_uid, ]
dim(X_train)
X_cv = X[cv_uid, ]
dim(X_cv)
rm(X)
temp = as(X_cv, "TsparseMatrix")
temp = data.table(i = temp@i, j = temp@j, x = temp@x)
temp[, history := sample(c(TRUE, FALSE), .N, replace = TRUE, prob = c(0.5, 0.5)), by = i]
head(temp)
X_cv_history = temp[history == TRUE]
X_cv_future = temp[history == FALSE]
rm(temp)
X_cv_history = sparseMatrix( i = X_cv_history$i, j = X_cv_history$j, x = X_cv_history$x,
dims = dim(X_cv), dimnames = dimnames(X_cv), index1 = FALSE)
X_cv_future = sparseMatrix( i = X_cv_future$i, j = X_cv_future$j, x = X_cv_future$x,
dims = dim(X_cv), dimnames = dimnames(X_cv), index1 = FALSE)

install.packages('rsparse')
library(rsparse)
model = WRMF$new(rank = 8)
make_confidence = function(x, alpha) {
x_confidence = x
stopifnot(inherits(x, "sparseMatrix"))
x_confidence@x = 1 + alpha * x@x
x_confidence
}
alpha = 0.1
X_train_conf = make_confidence(X_train, alpha)
X_cv_history_conf = make_confidence(X_cv_history, alpha)

RhpcBLASctl::blas_set_num_threads(1)
user_embeddings = model$fit_transform(X_train_conf, n_iter = 10L, n_threads = 8)

library(ggplot2)
trace = attr(user_embeddings, "trace")
g = ggplot(trace) + geom_line(aes(x = iter, y = value, col = scorer))
plotly::ggplotly(g, width = 9, height = NULL)

futile.logger::flog.threshold(futile.logger::ERROR)

RhpcBLASctl::blas_set_num_threads(1)

trace = NULL
alpha = c(0.01, 1)
rank = c(16, 8)
n_iter_max = 10L
n_threads = 8L
grid = expand.grid(alpha = alpha, rank = rank)
convergence_tol = 0.01
for(k in seq_len(nrow(grid))) {
alpha = grid$alpha[[k]]
rank = grid$rank[[k]]

futile.logger::flog.info("alpha = %.3f, rank = %d", alpha, rank)

model = WRMF$new(rank = rank)

X_train_conf = make_confidence(X_train, alpha)
X_cv_history_conf = make_confidence(X_cv_history, alpha)

fit model

user_embeddings = model$fit_transform(X_train_conf, n_iter = n_iter_max,
convergence_tol = convergence_tol, n_threads = n_threads)

store strace

grid_trace = attr(user_embeddings, "trace")

grid_trace$param_set = sprintf("alpha=%.3f; rank=%d", alpha, rank)
trace = c(trace, list(grid_trace))
}
trace = rbindlist(trace)
g = ggplot(trace) +
geom_line(aes(x = iter, y = value, col = param_set)) +
facet_wrap( ~ scorer, scales = "free") +
theme(legend.position="bottom")

plotly::ggplotly(g, width = 9, height = NULL)

@zakariaBensmida
Copy link

i tried this one but it does not work
actual = as(X_train_conf, "RsparseMatrix")
identical(rsparse::ap_k(user_embeddings[,7], actual), 1)
Error in rsparse::ap_k(user_embeddings[, 7], actual) :
is.matrix(predictions) is not TRUE

@dselivanov
Copy link
Owner

dselivanov commented Apr 25, 2019 via email

@zakariaBensmida
Copy link

sorry but i have soome idiot questions .is the below the predictions or only the seventh column is the predictions?
head(user_embeddings)
[,1] [,2] [,3] [,4] [,5] [,6]
00000c289a1829a808ac09c00daf10bc3c4e223b -4.4366019 -6.4496755 7.759140 4.0778027 3.021041 -2.5092545
00001411dc427966b17297bf4d69e7e193135d89 -3.8179604 -6.3121820 3.802888 -9.0638672 3.691029 1.5814032
00004d2ac9316e22dc007ab2243d6fcb239e707d -4.0583470 4.2391097 1.512497 -1.2811394 2.197221 -0.3218515
000063d3fe1cf2ba248b9e3c3f0334845a27a6bf -0.3175396 -0.2926188 2.726539 0.4600829 1.136645 -1.6827423
00007a47085b9aab8af55f52ec8846ac479ac4fe 0.8436100 2.6911790 2.080224 -3.6851317 2.073310 1.0996730
0000c176103e538d5c9828e695fed4f7ae42dd01 1.0942813 2.5679246 4.667832 -4.2642418 1.951552 2.3230622
[,7] [,8]
00000c289a1829a808ac09c00daf10bc3c4e223b 5.1683390 1.4608108
00001411dc427966b17297bf4d69e7e193135d89 5.2887858 -3.4221277
00004d2ac9316e22dc007ab2243d6fcb239e707d 3.8647705 -2.4137396
000063d3fe1cf2ba248b9e3c3f0334845a27a6bf 0.3753359 0.5390940
00007a47085b9aab8af55f52ec8846ac479ac4fe 5.4227957 -0.9695473
0000c176103e538d5c9828e695fed4f7ae42dd01 5.4995095 0.5390066

Repository owner locked as off-topic and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants