coreylynch / pyFM

Factorization machines in python
922 stars 311 forks source link

AttributeError: 'numpy.ndarray' object has no attribute 'indptr' #20

Open ks864148379 opened 7 years ago

ks864148379 commented 7 years ago

Creating validation dataset of 0.01 of training for adaptive regularization Traceback (most recent call last): File "suanfa.py", line 25, in fm.fit(trainX,trainY) File "/home/ks/anaconda3/lib/python3.5/site-packages/pyfm/pylibfm.py", line 181, in fit X_train_dataset = _make_dataset(X_train, train_labels) File "/home/ks/anaconda3/lib/python3.5/site-packages/pyfm/pylibfm.py", line 239, in _make_dataset dataset = CSRDataset(X.data, X.indptr, X.indices, y_i, sample_weight) AttributeError: 'numpy.ndarray' object has no attribute 'indptr'

mengwenliu commented 7 years ago

check if you add X = X.toarray(), which is wrong.

The following should work:

X = v.fit_transform(data) y = np.repeat(1.0, X.shape[0]) fm.fit(X, y)