-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.cpp
50 lines (42 loc) · 1.18 KB
/
client.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <jubatus/client.hpp>
using namespace std;
const string HOST = "127.0.0.1";
const int PORT = 9199;
const string NAME = "";
int main(int argc, char* argv[]) {
jubatus::recommender::client::recommender r(HOST, PORT, NAME, 5);
{
jubatus::client::common::datum d;
d.add_number("movie_A", 5);
d.add_number("movie_B", 2);
d.add_number("movie_C", 3);
r.update_row("user01", d);
}
{
jubatus::client::common::datum d;
d.add_number("movie_A", 2);
d.add_number("movie_B", 5);
d.add_number("movie_C", 1);
r.update_row("user02", d);
}
{
jubatus::client::common::datum d;
d.add_number("movie_A", 5);
d.add_number("movie_B", 1);
d.add_number("movie_C", 4);
r.update_row("user03", d);
}
vector<string> rows = r.get_all_rows();
for (size_t i = 0; i < rows.size(); i++) {
string id = rows[i];
std::vector<jubatus::recommender::id_with_score> result;
result = r.similar_row_from_id(id, 3);
cout << id << " is similar to: " << endl;
cout << " ";
for (size_t n = 0; n < result.size(); n++) {
cout << result[n].id << " (" << result[n].score << "), ";
}
cout << endl;
}
}