beechung / Latent-Factor-Models

R functions for fitting latent factor models with internal computation in C/C++
BSD 3-Clause "New" or "Revised" License
123 stars 61 forks source link

Running Error #12

Open guozhizou opened 8 years ago

guozhizou commented 8 years ago

Running src/LDA-RLFM/R/model/examples.R, I got following exception:

(B) Fit a model

dyn.load("c_funcs.so"); source("R/c_funcs.R"); source("R/utils.R"); source("R/model/MCEM_MStep.R"); source("R/model/fit.MCEM.R");

set.seed(2); ans = fit.MCEM(

  • nIter=5, # Number of EM iterations
  • nSamples=100, # Number of samples drawn in each E-step: could be a vector of size nIter.
  • nBurnIn=10, # Number of burn-in draws before take samples for the E-step: could be a vector of size nIter.
  • factor=data.train$factor, # Initial factor values
  • obs=data.train$obs, # Observed rating
  • feature=data.train$feature, # Feature values
  • param=data.train$param, # Initial parameter values
  • corpus=data.train$corpus, # The text corpus
  • try=list(lambda=c(0.5,1,2,4,8), eta=c(0.5, 1, 2, 4)), # Values of lambda and eta that you want to try
  • out.level=1, # out.level=1: Save the factor & parameter values to out.dir/est.highestCDL and out.dir/est.last
  • out.dir="/tmp/test/lda-rlfm", # out.level=2: Save the factor & parameter values of each iteration i to out.dir/est.i
  • out.append=FALSE,
  • debug=1, # Set to 0 to disable internal sanity checking; Set to 100 for most detailed sanity checking
  • verbose=1, # Set to 0 to disable console output; Set to 100 to print everything to the console
  • verbose.M=1, # Verbose setting for the M-step
  • use.C=TRUE, # Whether to use the C implementation (R implementation does not have full functionalities)
  • lm=T # Whether to use lm to fit linear regression (otherwise bayesglm will be used, which will be slow)
  • );

WARNING: Some terms do not belong to any items in the corpus.

* caught segfault * address 0x0, cause 'unknown'

Traceback: 1: .C("fillInTopicCounts", output$cnt_item_topic, output$cnt_topic_term, output$cnt_topic, output$z_avg, corpus_topic, corpus$item, corpus$term, corpus$weight, as.integer(nItems), as.integer(nrow(corpus)), as.integer(nTopics), as.integer(nTerms), as.integer(nCorpusWeights), as.integer(debug), DUP = FALSE) 2: getTopicCounts(corpus, factor$corpus_topic, nItems, nTopics, size$nTerms) 3: fit.MCEM(nIter = 5, nSamples = 100, nBurnIn = 10, factor = data.train$factor, obs = data.train$obs, feature = data.train$feature, param = data.train$param, corpus = data.train$corpus, try = list(lambda = c(0.5, 1, 2, 4, 8), eta = c(0.5, 1, 2, 4)), out.level = 1, out.dir = "/tmp/test/lda-rlfm", out.append = FALSE, debug = 1, verbose = 1, verbose.M = 1, use.C = TRUE, lm = T) An irrecoverable exception occurred. R is aborting now ...

Thanks for any help!

CodeSense10 commented 7 years ago

Hello, I am getting the same error. Any help will be deeply appreciated. @beechung Thanks.

beechung commented 7 years ago

I think the problem is because after R 3.x, R no long supports DUP=FALSE. The solution is to change from .C(...) to .Call(...) for the C code in src/LDA-RLFM/C/, in a way similar to the following commit.

https://github.com/beechung/Latent-Factor-Models/commit/1c3e0f50ec9dbb8cd84c30c91799d224eb893b01

narutolhy commented 7 years ago

When I use R 3.x, I have also encountered a lot of problems。 And I used R 2.x, those problems disappered

CodeSense10 commented 7 years ago

This solved the problem. Thanks a lot @beechung and @narutolhy .

CodeSense10 commented 7 years ago

There is another issue. In examples.R, line 267: library(arm) is generating an error- Error in library(arm) : there is no package called ‘arm’ I have placed the arms.c and arms.h files in arslogistic and yet face this problem. @narutolhy

beechung commented 7 years ago

To install a R package, use the following command: install.packages("arm")

You need to first install it before you can use it.

CodeSense10 commented 7 years ago

@beechung I used R 2.15.3 instead of R 3.x and that solved the initial problem and the subsequent problems that were present despite changing .C(...) to .Call(...). The current problem is that "arm" package is not available for R 2.15.3. Can you suggest a work around? Also I want to implement fLDA for my own dataset but I could not find reIndexData and indexTestData as mentioned in prediction.R or any explanation about the dataset used in this code.