maciejkula / spotlight

Deep recommender models using PyTorch.
MIT License
2.97k stars 421 forks source link

"Only integer scalar arrays can be converted to a scalar index" #148

Closed pugantsov closed 5 years ago

pugantsov commented 5 years ago

When I add timestamps to my interactions matrix, which builds completely fine, I get this:

Traceback (most recent call last):
  File "model_spotlight.py", line 105, in <module>
    sim.run()
  File "model_spotlight.py", line 96, in run
    train, test = self.cross_validation(implicit_interactions)
  File "model_spotlight.py", line 64, in cross_validation
    train, test = random_train_test_split(interactions)
  File "/home/alex/anaconda3/envs/recsys/lib/python3.6/site-packages/spotlight/cross_validation.py", line 83, in random_train_test_split
    random_state=random_state)
  File "/home/alex/anaconda3/envs/recsys/lib/python3.6/site-packages/spotlight/cross_validation.py", line 51, in shuffle_interactions
    shuffle_indices),
  File "/home/alex/anaconda3/envs/recsys/lib/python3.6/site-packages/spotlight/cross_validation.py", line 17, in _index_or_none
    return array[shuffle_index]
TypeError: only integer scalar arrays can be converted to a scalar index
pugantsov commented 5 years ago

Just realised this is because I tried to pass a list which wasn't cast as an np.array, as a warning to whoever else is getting this.