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

Segmentation fault (core dumped) #17

Open
ahojukka5 opened this issue Aug 12, 2024 · 1 comment
Open

Segmentation fault (core dumped) #17

ahojukka5 opened this issue Aug 12, 2024 · 1 comment

Comments

@ahojukka5
Copy link

Trying out toy model from documentation causes segmentation fault.

import myfm
from sklearn.feature_extraction import DictVectorizer
import numpy as np
train = [
    {"user": "1", "item": "5", "age": 19},
    {"user": "2", "item": "43", "age": 33},
    {"user": "3", "item": "20", "age": 55},
    {"user": "4", "item": "10", "age": 20},
]
v = DictVectorizer()

X = v.fit_transform(train)

# Note that X is a sparse matrix
print(X.toarray())

# The target variable to be classified.
y = np.asarray([0, 1, 1, 0])
fm = myfm.MyFMClassifier(rank=4)
print("fit")
fm.fit(X,y)
print("fit done")

# It also supports prediction for new unseen items.
fm.predict_proba(v.transform([{"user": "1", "item": "10", "age": 24}]))
$ python test.py 
[[19.  0.  0.  0.  1.  1.  0.  0.  0.]
 [33.  0.  0.  1.  0.  0.  1.  0.  0.]
 [55.  0.  1.  0.  0.  0.  0.  1.  0.]
 [20.  1.  0.  0.  0.  0.  0.  0.  1.]]
fit
  0%|                                                                                                                                         | 0/100 [00:00<?, ?it/s]Segmentation fault (core dumped)
@tohtsky
Copy link
Owner

tohtsky commented Nov 12, 2024

@ahojukka5
Sorry for the late reply! And thanks for reporting the problem. I was able to reproduce the issue.

It appears that the problem occurs in myFM with numpy version >= 2.0.0. Could you try downgrading numpy to 1.x.x? I will try to solve the problem when I have time.

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

2 participants