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

Cast error for document-term matrix with binary logistic slda #8

Open
kwajiehao opened this issue May 17, 2018 · 0 comments
Open

Cast error for document-term matrix with binary logistic slda #8

kwajiehao opened this issue May 17, 2018 · 0 comments

Comments

@kwajiehao
Copy link

hi @burbma, @bearnshaw , thanks for the package, it's been super useful so far. I ran into some issues when trying using blslda.fit(). I used the sklearn package to generate the document-term matrix, but when I tried to pass it into the blslda.fit() function I got the error : "Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe'".

The full traceback is:

TypeError Traceback (most recent call last)
~/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
51 result = wrap(result)
---> 52 return result
53

TypeError: Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe'

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last)
in ()

~/anaconda3/lib/python3.6/site-packages/slda/topic_models.py in fit(self, X, y)
286 self.n_docs, self.n_terms = X.shape
287 self.n_tokens = X.sum()
--> 288 doc_lookup, term_lookup = self._create_lookups(X)
289 # iterate
290 self.theta, self.phi, self.eta, self.loglikelihoods = gibbs_sampler_blslda(

~/anaconda3/lib/python3.6/site-packages/slda/topic_models.py in _create_lookups(self, X)
37 else:
38 x = X[docs, terms]
---> 39 doc_lookup = np.ascontiguousarray(np.repeat(docs, x), dtype=np.intc)
40 term_lookup = np.ascontiguousarray(np.repeat(terms, x), dtype=np.intc)
41 return doc_lookup, term_lookup

~/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py in repeat(a, repeats, axis)
421 mode : {'raise', 'wrap', 'clip'}, optional
422 Specifies how out-of-bounds indices will behave.
--> 423
424 * 'raise' -- raise an error (default)
425 * 'wrap' -- wrap around

~/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
60 # such a method in its class.
61
---> 62 # A TypeError occurs if the object does have such a method
63 # in its class, but its signature is not identical to that
64 # of NumPy's. This situation has occurred in the case of

~/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapit(obj, method, *args, **kwds)
40
41 # functions that are now methods
---> 42 def _wrapit(obj, method, *args, **kwds):
43 try:
44 wrap = obj.array_wrap

TypeError: Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe'

Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant