Module TryExcept body Import alias identifier handlers ExceptHandler type NameLoad body Import alias Import alias identifier ImportFrom alias ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults Num NameLoad NameLoad body Expr Str Raise Call NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Raise Call NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If UnaryOpNot Call AttributeLoad NameLoad attr Str body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad Call NameLoad NameLoad Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Pass decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad If Call NameLoad NameLoad NameLoad body Assign NameStore NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad SubscriptLoad NameLoad Index Str Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Pass decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword Str If Call NameLoad NameLoad NameLoad body Assign NameStore NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad SubscriptLoad NameLoad Index Str Return Call NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam defaults body If Call NameLoad NameLoad Str body Return AttributeLoad NameLoad attr Return Str decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults Num NameLoad NameLoad NameLoad body Expr Str Assign NameStore ListLoad For NameStore Call NameLoad AttributeLoad NameLoad attr body If BoolOpAnd NameLoad CompareEq BinOpMod NameLoad Num Num body Print NameLoad Str Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad If NameLoad body Print Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults Num NameLoad NameLoad body Expr Str Return ListComp Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore AttributeLoad NameLoad attr If Call NameLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr orelse Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore BinOpMult NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr For NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num body Assign TupleStore NameStore NameStore TupleLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad SubscriptLoad AttributeLoad NameLoad attr Index BinOpAdd NameLoad Num If CompareGt NameLoad NameLoad body Assign SubscriptStore NameLoad Slice NameLoad NameLoad NameLoad Return BinOpSub NameLoad Call NameLoad TupleLoad NameLoad TupleLoad NameLoad NameLoad keyword AttributeLoad NameLoad attr decorator_list decorator_list
N/A N/A N/A N/A cPickle pickle N/A N/A N/A ImportError N/A N/A pickle N/A numpy np scipy.sparse csr_matrix BaseRecommender N/A object N/A N/A 
    Minimal interface to be implemented by recommenders, along with
    some helper methods. A concrete recommender must implement the
    recommend_items() method and should provide its own implementation
    of __str__() so that it can be identified when printing results.

    Notes
    =====
    In most cases you should inherit from either
    `mrec.mf.recommender.MatrixFactorizationRecommender` or
    `mrec.item_similarity.recommender.ItemSimilarityRecommender`
    and *not* directly from this class.

    These provide more efficient implementations of save(), load()
    and the batch methods to recommend items.
     recommend_items N/A N/A self dataset u max_items return_scores item_features N/A 10 True None N/A N/A 
        Recommend new items for a user.

        Parameters
        ==========
        dataset : scipy.sparse.csr_matrix
            User-item matrix containing known items.
        u : int
            Index of user for which to make recommendations.
        max_items : int
            Maximum number of recommended items to return.
        return_scores : bool
            If true return a score along with each recommended item.
        item_features : array_like, shape = [num_items, num_features]
            Optionally supply features for each item in the dataset.

        Returns
        =======
        recs : list
            List of (idx,score) pairs if return_scores is True, else
            just a list of idxs.
         N/A N/A NotImplementedError you must implement recommend_items() N/A fit N/A N/A self train item_features N/A None N/A N/A 
        Train on supplied data. In general you will want to
        implement this rather than computing recommendations on
        the fly.

        Parameters
        ==========
        train : scipy.sparse.csr_matrix or mrec.sparse.fast_sparse_matrix, shape = [num_users, num_items]
            User-item matrix.
        item_features : array_like, shape = [num_items, num_features]
            Features for items in training set, required by some recommenders.
         N/A N/A NotImplementedError you should implement fit() N/A save N/A N/A self filepath N/A N/A N/A 
        Serialize model to file.

        Parameters
        ==========
        filepath : str
            Filepath to write to, which must have the '.npz' suffix.

        Notes
        =====
        Internally numpy.savez may be used to serialize the model and
        this would add the '.npz' suffix to the supplied filepath if
        it were not already present, which would most likely cause errors
        in client code.
         N/A N/A N/A N/A filepath endswith .npz N/A N/A N/A ValueError N/A N/A invalid filepath {0}, must have ".npz" suffix format filepath N/A archive N/A N/A self _create_archive N/A archive N/A N/A N/A N/A np savez filepath archive N/A N/A N/A N/A pickle dump self N/A open filepath w N/A _create_archive N/A N/A self N/A N/A N/A 
        Optionally return a dict of fields to be serialized
        in a numpy archive: this lets you store arrays efficiently
        by separating them from the model itself.

        Returns
        =======
        archive : dict
            Fields to serialize, must include the model itself
            under the key 'model'.
         N/A N/A load N/A N/A filepath N/A N/A N/A 
        Load a recommender model from file after it has been serialized with
        save().

        Parameters
        ==========
        filepath : str
            The filepath to read from.
         N/A r N/A N/A np load filepath N/A N/A isinstance r BaseRecommender N/A N/A model r N/A N/A model N/A N/A np loads N/A str N/A r N/A model N/A N/A N/A model _load_archive r N/A model N/A staticmethod _load_archive N/A N/A archive N/A N/A N/A 
        Load fields from a numpy archive.

        Notes
        =====
        This is called by the static load() method and should be used
        to restore the fields returned by _create_archive().
         N/A N/A read_recommender_description N/A N/A filepath N/A N/A N/A 
        Read a recommender model description from file after it has
        been saved by save(), without loading any additional
        associated data into memory.

        Parameters
        ==========
        filepath : str
            The filepath to read from.
         N/A r N/A N/A np load filepath mmap_mode r N/A N/A isinstance r BaseRecommender N/A N/A model r N/A N/A model N/A N/A np loads N/A str N/A r N/A model N/A N/A str model N/A staticmethod __str__ N/A N/A self N/A N/A N/A N/A hasattr self description N/A N/A N/A self description N/A unspecified recommender: you should set self.description or implement __str__() N/A batch_recommend_items N/A N/A self dataset max_items return_scores show_progress item_features N/A 10 True False None N/A N/A 
        Recommend new items for all users in the training dataset.

        Parameters
        ==========
        dataset : scipy.sparse.csr_matrix
            User-item matrix containing known items.
        max_items : int
            Maximum number of recommended items to return.
        return_scores : bool
            If true return a score along with each recommended item.
        show_progress: bool
            If true print something to stdout to show progress.
        item_features : array_like, shape = [num_items, num_features]
            Optionally supply features for each item in the dataset.

        Returns
        =======
        recs : list of lists
            Each entry is a list of (idx,score) pairs if return_scores is True,
            else just a list of idxs.

        Notes
        =====
        This provides a default implementation, you will be able to optimize
        this for most recommenders.
         N/A recs N/A N/A u N/A xrange N/A self num_users N/A N/A N/A show_progress N/A N/A u 1000 0 N/A N/A u .. N/A N/A N/A recs append N/A N/A self recommend_items dataset u max_items return_scores N/A show_progress N/A N/A N/A recs N/A range_recommend_items N/A N/A self dataset user_start user_end max_items return_scores item_features N/A 10 True None N/A N/A 
        Recommend new items for a range of users in the training dataset.

        Parameters
        ==========
        dataset : scipy.sparse.csr_matrix
            User-item matrix containing known items.
        user_start : int
            Index of first user in the range to recommend.
        user_end : int
            Index one beyond last user in the range to recommend.
        max_items : int
            Maximum number of recommended items to return.
        return_scores : bool
            If true return a score along with each recommended item.
        item_features : array_like, shape = [num_items, num_features]
            Optionally supply features for each item in the dataset.

        Returns
        =======
        recs : list of lists
            Each entry is a list of (idx,score) pairs if return_scores is True,
            else just a list of idxs.

        Notes
        =====
        This provides a default implementation, you will be able to optimize
        this for most recommenders.
         N/A N/A N/A N/A self recommend_items dataset u max_items return_scores N/A u N/A xrange user_start user_end N/A _zero_known_item_scores N/A N/A self r train N/A N/A N/A 
        Helper function to set predicted scores/ratings for training items
        to zero or less, to avoid recommending already known items.

        Parameters
        ==========
        r : numpy.ndarray or scipy.sparse.csr_matrix
            Predicted scores/ratings.
        train : scipy.sparse.csr_matrix
            The training user-item matrix, which can include zero-valued entries.

        Returns
        =======
        r_safe : scipy.sparse.csr_matrix
            r_safe is equal to r except that r[u,i] <= 0 for all u,i with entries
            in train.
         N/A col N/A train indices N/A N/A isinstance r csr_matrix N/A N/A max_score N/A N/A N/A r data max N/A N/A max_score N/A N/A r max N/A data N/A max_score N/A N/A np ones N/A col shape N/A row N/A N/A np zeros N/A col shape N/A u N/A xrange N/A N/A train shape N/A 0 N/A N/A N/A start end N/A N/A N/A train indptr N/A u N/A N/A train indptr N/A N/A u 1 N/A N/A end start N/A N/A N/A row N/A start end u N/A N/A r N/A csr_matrix N/A data N/A row col shape N/A r shape N/A N/A