Turi Create  4.0
user_item_lists.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_RECSYS_USER_ITEM_LISTS_H_
7 #define TURI_RECSYS_USER_ITEM_LISTS_H_
8 
9 #include <toolkits/ml_data_2/ml_data.hpp>
10 #include <core/storage/sframe_data/sframe.hpp>
11 #include <memory>
12 #include <vector>
13 
14 namespace turi { namespace recsys {
15 
16 /** Make users' (item, rating) lists by user.
17  *
18  * In this case, the ml_data structure for the user-item lists is
19  * must be sorted by rows, with the first column being the user
20  * column.
21  *
22  * This operation is done without loading the data into memory.
23  *
24  * The user column is assumed to be the first column, and the item
25  * column is assumed to be the second column.
26  *
27  * \param[in] data An ml_data object sorted first by users (first
28  * column), then by items (second column).
29  *
30  * \return An SArray of vectors of pairs of flex_int, flex_float, where the
31  * first index is the item and the second index is the rating.
32  */
33 std::shared_ptr<sarray<std::vector<std::pair<size_t, double> > > >
34 make_user_item_lists(const v2::ml_data& data);
35 
36 }}
37 
38 #endif /* _USER_ITEM_LISTS_H_ */