Giter Site home page Giter Site logo

Comments (3)

david-cortes avatar david-cortes commented on May 23, 2024

In your screenshot, it looks like you haven't loaded the library with library(cmfrec). In the example code, looks like you are passing a different object at the end.

This library doesn't do multiple topN predictions btw.

from cmfrec.

DanielRauser avatar DanielRauser commented on May 23, 2024

Hello,

sorry for the mistake. Here you see the fixed code. But I still have an error message.

Best regards,

Daniel


library(cmfrec)

X <- as.coo.matrix(Matrix_model_4@data)

reco_split <- create.reco.train.test(
    X,
    users_test_fraction = 0.2,
    items_test_fraction = 0.3,
    min_pos_test = 2,
    seed = 123
)

X_train <- reco_split$X_train ## Train data for test users
X_test <- reco_split$X_test ## Test data for test users
X_rem <- reco_split$X_rem ## Data to fit the model
users_test <- reco_split$users_test ## IDs of the test users

### Random recommendations (random latent factors)
set.seed(123)
UserFactors_random <- matrix(rnorm(nrow(X_test) * 5), nrow=5)
ItemFactors_random <- matrix(rnorm(ncol(X_test) * 5), nrow=5)

### Non-personalized recommendations
model_baseline <- cmfrec::MostPopular(as.coo.matrix(X_rem), implicit=TRUE)
item_biases <- model_baseline$matrices$item_bias


model_iALS <- CMF_implicit(as.coo.matrix(X_rem), k=16, lambda = 0.1, alpha = 0.01, niter = 16L)

pred_iALS <- predict(model_iALS, X_test)

image

from cmfrec.

david-cortes avatar david-cortes commented on May 23, 2024

It looks like you're trying to pass a dgRMatrix to predict, which is not supported (only dgTMatrix). You can check the docs for more details. It also looks like you are using an older version of this package as I'd see a different error if I try to execute your code.

from cmfrec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.