6 #ifndef TURI_RECSYS_MODEL_POPULARITY_H_ 7 #define TURI_RECSYS_MODEL_POPULARITY_H_ 11 #include <toolkits/recsys/recsys_model_base.hpp> 12 #include <toolkits/nearest_neighbors/nearest_neighbors.hpp> 13 #include <toolkits/nearest_neighbors/ball_tree_neighbors.hpp> 27 class EXPORT recsys_popularity :
public recsys_model_base {
31 void init_options(
const std::map<std::string, flexible_type>&_options)
override;
33 bool use_target_column(
bool target_is_present)
const override {
34 return target_is_present;
43 std::map<std::string, flexible_type> train(
const v2::ml_data& data)
override;
46 #pragma clang diagnostic push 47 #pragma clang diagnostic ignored "-Woverloaded-virtual" // TODO: fix this issue 49 std::map<std::string, flexible_type> train(
50 std::shared_ptr<sarray<std::vector<std::pair<size_t, double> > > > trained_user_item);
52 #pragma clang diagnostic pop 55 sframe predict(
const v2::ml_data& test_data)
const override;
57 sframe get_similar_items(std::shared_ptr<sarray<flexible_type>> items,
58 size_t k=0)
const override;
60 sframe get_similar_users(std::shared_ptr<sarray<flexible_type>> users,
61 size_t k=0)
const override;
64 std::vector<std::pair<size_t, double> >& scores,
65 const std::vector<v2::ml_data_entry>& query_row,
67 const std::vector<std::pair<size_t, double> >& user_item_list,
68 const std::vector<std::pair<size_t, double> >& new_user_item_data,
69 const std::vector<v2::ml_data_row_reference>& new_observation_data,
70 const std::shared_ptr<v2::ml_data_side_features>& known_side_features)
const override;
74 static constexpr
size_t POPULARITY_RECOMMENDER_VERSION = 0;
76 inline size_t internal_get_version()
const override {
77 return POPULARITY_RECOMMENDER_VERSION;
83 std::vector<double> item_predictions;
84 double unseen_item_prediction;
85 std::shared_ptr<nearest_neighbors::ball_tree_neighbors> nearest_items_model;
#define BEGIN_CLASS_MEMBER_REGISTRATION(python_facing_classname)
The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities.
#define IMPORT_BASE_CLASS_REGISTRATION(base_class)
#define END_CLASS_MEMBER_REGISTRATION
The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities.