1111#include < pgvector/pqxx.hpp>
1212#include < pqxx/pqxx>
1313
14- using disco::Dataset;
15- using disco::Recommender;
16-
1714std::string convert_to_utf8 (const std::string& str) {
1815 std::stringstream buf;
1916 for (const unsigned char v : str) {
@@ -26,7 +23,7 @@ std::string convert_to_utf8(const std::string& str) {
2623 return buf.str ();
2724}
2825
29- Dataset<int , std::string> load_movielens (const std::string& path) {
26+ disco:: Dataset<int , std::string> load_movielens (const std::string& path) {
3027 std::string line;
3128
3229 // read movies
@@ -42,7 +39,7 @@ Dataset<int, std::string> load_movielens(const std::string& path) {
4239 }
4340
4441 // read ratings and create dataset
45- Dataset<int , std::string> data;
42+ disco:: Dataset<int , std::string> data;
4643 std::ifstream ratings_file (path + " /u.data" );
4744 if (!ratings_file.is_open ()) {
4845 throw std::runtime_error{" Could not open file" };
@@ -78,8 +75,8 @@ int main() {
7875 tx.exec (" CREATE TABLE users (id integer PRIMARY KEY, factors vector(20))" );
7976 tx.exec (" CREATE TABLE movies (name text PRIMARY KEY, factors vector(20))" );
8077
81- Dataset<int , std::string> data = load_movielens (movielens_path);
82- auto recommender = Recommender<int , std::string>::fit_explicit (data, {.factors = 20 });
78+ disco:: Dataset<int , std::string> data = load_movielens (movielens_path);
79+ auto recommender = disco:: Recommender<int , std::string>::fit_explicit (data, {.factors = 20 });
8380
8481 for (const auto & user_id : recommender.user_ids ()) {
8582 pgvector::Vector factors{*recommender.user_factors (user_id)};
0 commit comments