-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from maciejkula/goodbooks
Add goodbooks dataset
- Loading branch information
Showing
6 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ Datasets | |
|
||
Synthetic <synthetic> | ||
Movielens <movielens> | ||
Goodbooks <goodbooks> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Goodbooks | ||
========= | ||
|
||
|
||
.. automodule:: spotlight.datasets.goodbooks | ||
:members: | ||
:undoc-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
Utilities for fetching the Goodbooks-10K dataset [1]_. | ||
References | ||
---------- | ||
.. [1] https://github.com/zygmuntz/goodbooks-10k | ||
""" | ||
|
||
import h5py | ||
|
||
import numpy as np | ||
|
||
from spotlight.datasets import _transport | ||
from spotlight.interactions import Interactions | ||
|
||
|
||
def _get_dataset(): | ||
|
||
path = _transport.get_data('https://github.com/zygmuntz/goodbooks-10k/' | ||
'releases/download/v1.0/goodbooks-10k.hdf5', | ||
'goodbooks', | ||
'goodbooks.hdf5') | ||
|
||
with h5py.File(path, 'r') as data: | ||
return (data['ratings'][:, 0], | ||
data['ratings'][:, 1], | ||
data['ratings'][:, 2], | ||
np.arange(len(data['ratings']), dtype=np.int32)) | ||
|
||
|
||
def get_goodbooks_dataset(): | ||
""" | ||
Download and return the goodbooks-10K dataset [2]_. | ||
Returns | ||
------- | ||
Interactions: :class:`spotlight.interactions.Interactions` | ||
instance of the interactions class | ||
References | ||
---------- | ||
.. [2] https://github.com/zygmuntz/goodbooks-10k | ||
""" | ||
|
||
return Interactions(*_get_dataset()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters