Skip to content

Commit

Permalink
Updated doc + corrected examples
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug committed Dec 28, 2016
1 parent daf6677 commit dcad442
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ TODO
* Make cleaner paper citations
* Check out the yelp dataset
* See if we could compute similarity on the fly (see issue #3)
* use `expanduser` in all examples
* correct note on raw/inner ids (strings or whaterver)

Maybe, Maybe not
----------------
Expand Down
20 changes: 10 additions & 10 deletions doc/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Load an entire dataset
.. literalinclude:: ../../examples/load_custom_dataset.py
:caption: From file ``examples/load_custom_dataset.py``
:name: load_custom_dataset.py
:lines: 16-25
:lines: 17-26

.. note::
Actually, as the Movielens-100k dataset is builtin, `Surprise
Expand Down Expand Up @@ -149,20 +149,20 @@ is call the :meth:`predict()
If the :meth:`predict()
<surprise.prediction_algorithms.algo_base.AlgoBase.predict>` method is called
with user or item ids that were not part of the trainset, it's up to the
algorithm to decide if he still can make a prediction or not. If it can't,
algorithm to decide if it still can make a prediction or not. If it can't,
:meth:`predict() <surprise.prediction_algorithms.algo_base.AlgoBase.predict>`
will still predict the mean of all ratings :math:`\mu`.

.. _raw_inner_note:
.. note::
Raw ids are ids as defined in a rating file. They can be strings or whatever.
On trainset creation, each raw id is mapped to a (unique) integer called
inner id, which is a lot more suitable for `Surprise
<https://nicolashug.github.io/Surprise/>`_ to manipulate. To convert a raw id
to an inner id, you can use the :meth:`to_inner_uid()
<surprise.dataset.Trainset.to_inner_uid>` and :meth:`to_inner_iid()
<surprise.dataset.Trainset.to_inner_iid>` methods of the :class:`trainset
<surprise.dataset.Trainset>`.
Raw ids are ids as defined in a rating file. They can be strings, numbers, or
whatever (but are still represented as strings). On trainset creation, each
raw id is mapped to a unique integer called inner id, which is a lot more
suitable for `Surprise <https://nicolashug.github.io/Surprise/>`_ to
manipulate. To convert a raw id to an inner id, you can use the
:meth:`to_inner_uid() <surprise.dataset.Trainset.to_inner_uid>` and
:meth:`to_inner_iid() <surprise.dataset.Trainset.to_inner_iid>` methods of
the :class:`trainset <surprise.dataset.Trainset>`.

Obviously, it is perfectly fine to use the :meth:`predict()
<surprise.prediction_algorithms.algo_base.AlgoBase.predict>` method directly
Expand Down
3 changes: 2 additions & 1 deletion examples/load_custom_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os

from surprise import BaselineOnly
from surprise import Dataset
from surprise import evaluate
from surprise import Reader

# path to dataset file
file_path = '/home/nico/.surprise_data/ml-100k/ml-100k/u.data' # change this
file_path = os.path.expanduser('~/.surprise_data/ml-100k/ml-100k/u.data')

# As we're loading a custom dataset, we need to define a reader. In the
# movielens-100k dataset, each line has the following format:
Expand Down
2 changes: 1 addition & 1 deletion examples/load_custom_dataset_predefined_folds.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from surprise import Reader

# path to dataset folder
files_dir = os.path.exapanduser('~/.surprise_data/ml-100k/ml-100k/')
files_dir = os.path.expanduser('~/.surprise_data/ml-100k/ml-100k/')

# This time, we'll use the built-in reader.
reader = Reader('ml-100k')
Expand Down
12 changes: 6 additions & 6 deletions surprise/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def knows_user(self, uid):
A user is part of the trainset if the user has at least one rating.
Args:
uid: The (inner) user id. See :ref:`this note<raw_inner_note>`.
uid(int): The (inner) user id. See :ref:`this note<raw_inner_note>`.
Returns:
``True`` if user is part of the trainset, else ``False``.
"""
Expand All @@ -515,7 +515,7 @@ def knows_item(self, iid):
An item is part of the trainset if the item was rated at least once.
Args:
iid: The (inner) item id. See :ref:`this note<raw_inner_note>`.
iid(int): The (inner) item id. See :ref:`this note<raw_inner_note>`.
Returns:
``True`` if item is part of the trainset, else ``False``.
"""
Expand All @@ -528,10 +528,10 @@ def to_inner_uid(self, ruid):
See :ref:`this note<raw_inner_note>`.
Args:
ruid: The user raw id.
ruid(str): The user raw id.
Returns:
The user inner id.
int: The user inner id.
Raises:
ValueError: When user is not part of the trainset.
Expand All @@ -549,10 +549,10 @@ def to_inner_iid(self, riid):
See :ref:`this note<raw_inner_note>`.
Args:
riid: The item raw id.
riid(str): The item raw id.
Returns:
The item inner id.
int: The item inner id.
Raises:
ValueError: When item is not part of the trainset.
Expand Down

0 comments on commit dcad442

Please sign in to comment.