Jubatus::Recommender::Client - Perl extension for interfacing with recommendation server 'jubarecommender'
use Jubatus; my $juba_client_type = "recommender"; my $host_name_or_ip_address = "localhost"; # master node's my $port_number_of_juba_process = 13714; # meanless my $cluster_name = "jubatus_perl_doc"; # even if it isn't in a distributed environment using ZooKeeper and Jubatus keepers. # you can select from (recommender | regression | classifier | stat | graph | anomaly | nearestneighbor | clustering) my $reco_client = Jubatus->get_client($juba_client_type, $host_name_or_ip_address, $port_number_of_juba_process, $cluster_name); # got Jubatus::Recommender::Client object # In the following example, get maximum value from sample array using Jubatus::Recommender::Client object my $is_clear = $reco_client->clear(); { # You can use an array reference of array references to initialize the Jubatus::Common::Datum object my $row_id = "red"; my $values = [["name", "red"], ["image", "warm"], ["R", 255.0], ["G", 0.0], ["B", 0.0]]; my $datum = Jubatus::Common::Datum->new($string_values, $num_values); my $is_update = $reco_client->update_row($row_id, $datum); } { # And also you can use an hash to initialize the Jubatus::Common::Datum object my $row_id = "blue"; my $hash = { "name" => "blue", "image" => "cold", "R" => 0.0, "G" => 0.0, "B" => 255.0 }; my $datum = Jubatus::Common::Datum->new($hash); my $is_update = $reco_client->update_row($row_id, $datum); } { my $row_id = "cyan"; my $values = [["name", "cyan"], ["image", "cold"], ["R", 0.0], ["G", 255.0], ["B", 255.0]]; my $datum = Jubatus::Common::Datum->new($values); my $is_update = $reco_client->update_row($row_id, $datum); } { my $row_id = "magenta"; my $values = [["name", "magenta"], ["image", "warm"], ["R", 255.0], ["G", 0.0], ["B", 255.0]]; my $datum = Jubatus::Common::Datum->new($values); my $is_update = $reco_client->update_row($row_id, $datum); } { my $row_id = "yellow"; my $values = [["name", "yellow"], ["image", "warm"], ["R", 255.0], ["G", 255.0], ["B", 0.0]]; my $datum = Jubatus::Common::Datum->new($values); my $is_update = $reco_client->update_row($row_id, $datum); } { my $row_id = "green"; my $values = [["name", "green"], ["image", "cold"], ["R", 0.0], ["G", 255.0], ["B", 0.0]]; my $datum = Jubatus::Common::Datum->new($values); my $max_result_num = 10; my $similar_row = $reco_client->similar_row_from_datum($datum, $max_result_num); # return cyan, yellow, blue my $is_update = $reco_client->update_row($row_id, $datum); } { my $similar_row = $reco_client->similar_row_from_id("green", $max_result_num); # return green, cyan, yellow, blue }
This module provide a interface of recommendation server 'jubarecommender' by TCP-based MessagePack RPC protocol using AnyEvent::MPRPC::Client
Jubatus::Recommender::Client provide many methods.
This constructors can die when invalid parameters are given.
This code will create Jubatus::Recommender::Client object and return it. You should set $host and $port in agreement to running jubastat server application.
use Jubatus::Recommender::Client; my $host = 'localhost'; my $port = '13714'; my $obj = Jubatus::Recommender::Client->new($host, $port);
The above code is equivalent to:
use Jubatus; my $host = 'localhost'; my $port = '13714'; my $juba_client_type = 'recommender'; my $reco_client = Jubatus->get_client($host, $port, $juba_client_type);
See Jubatus for more detail.
You must set $cluster_name if you are distributed environment user.
use Jubatus::Recommender::Client; my $host = 'localhost'; my $port = '13714'; my $cluster_name = "perl doc"; my $obj = Jubatus::Recommender::Client->new($host, $port, $cluster_name);
use Jubatus; my $juba_client_type = 'recommender'; my $host = 'localhost'; my $port = '13714'; my $cluster_name = "perl doc"; my $reco_client = Jubatus->get_client($juba_client_type, $host, $port, $cluster_name);
Default value of timeout parameter of server process is 10 seconds. If you want to set timeout parameter, you should set 4th argument.
use Jubatus::Recommender::Client; my $host = 'localhost'; my $port = '13714'; my $cluster_name = "perl doc"; my $timeout_secondes = 10; my $obj = Jubatus::Recommender::Client->new($host, $port, $cluster_name, $timeout_secondes);
use Jubatus; my $juba_client_type = 'recommender'; my $host = 'localhost'; my $port = '13714'; my $cluster_name = "perl doc"; my $timeout_secondes = 10; my $reco_client = Jubatus->get_client($juba_client_type, $host, $port, $cluster_name, $timeout_secondes);
Returns the reference to the Jubatus::Recommender::Client object which has a "client" field. This field is a reference of AnyEvent::MPRPC::Client object to call a raw MessagePack-RPC client instance which is used by Jubatus client libraries. The functions of Jubatus::Recommender::Client are wrapper of AnyEvent::MPRPC::Client.
Input:
- None
Output:
- Jubatus::Recommender::Client object - Return a Jubatus::Recommender::Client object Which is used ad MessagePack-RPC client instance of jubarecommender server.
Returns a server configuration from a server which is belonging to the cluster which execute the $cluster_name tasks.
- none
- JSON file formated string - Returns a server configuration from a server. This configuration is same as the configuration file which was assigned when you start the jubarecommender server.
Returns server status from all servers which are belonging to the cluster which execute the $cluster_name tasks. Each server is represented by a pair of a host name and a port number.
Stores the learning model as $save_file_name to the local disk of all servers which are belonging to the cluster which execute the $cluster_name tasks.
- $save_file_name - File name to save
- binary(1 or 0) - Return integer value 1 if this function saves files successfully at all servers
Restores the saved model using $load_file_name at the local disk of all servers which are belonging to the cluster which execute the $cluster_name tasks.
- $load_file_name - File name to restore
- binary(1 or 0) - Return integer value 1 if this function restore saved model successfully at all servers
Completely clears the learning model on the memory of all servers which are belonging to the cluster which execute the $cluster_name tasks.
- binary(1 or 0) - Return integer value 1 if this function clears the saved model successfully at all servers
- Hash reference which have a hash reference value - Returns a server status from all servers which are belonging to the cluster which execute the $cluster_name tasks. Each server is represented by a pair of host name and a port number. This pair is used for a key of the return hash reference. The value of the return hash reference is hash reference. The keys of this hash reference are the server status name and each values are the server status informations.
http://jubat.us/ https://github.com/jubatus
AnyEvent::MPRPC AnyEvent::MPRPC::Client http://msgpack.org/ http://wiki.msgpack.org/display/MSGPACK/RPC+specification
https://github.com/overlast/p5-Jubatus
Copyright (C) 2013 by Toshinori Sato (@overlast).
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Toshinori Sato (@overlast) <overlasting@gmail.com>
To install Jubatus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Jubatus
CPAN shell
perl -MCPAN -e shell install Jubatus
For more information on module installation, please visit the detailed CPAN module installation guide.