def setUp(self):
        self.config = {
            "method": "inverted_index",
            "converter": {
                "string_filter_types": {},
                "string_filter_rules": [],
                "num_filter_types": {},
                "num_filter_rules": [],
                "string_types": {},
                "string_rules": [{"key": "*", "type": "str", "sample_weight": "bin", "global_weight": "bin"}],
                "num_types": {},
                "num_rules": [{"key": "*", "type": "num"}],
            },
            "parameter": {},
        }

        TestUtil.write_file("config_recommender.json", json.dumps(self.config))
        self.srv = TestUtil.fork_process("recommender", port, "config_recommender.json")
        self.cli = recommender(host, port)
Exemple #2
0
import calendar
from jubatus.recommender.client import recommender
from jubatus.recommender.types import *

typhoon_client = recommender('127.0.0.1', 9199)
harvest_client = recommender('127.0.0.1', 9299)

method = "inverted_index"
converter = """
  {
    \"string_filter_types\" : {},
    \"string_filter_rules\" : [],
    \"num_filter_types\" : {},
    \"num_filter_rules\" : [],
    \"string_types\" : {},
    \"string_rules\" : [],
    \"num_types\" : {},
    \"num_rules\" : [
      {
        \"key\" : \"*\",
        \"type\" : \"num\"
      }
    ]
  }
"""
config = config_data(method, converter)

# train -- typhoon
typhoon_client.set_config('', config)
typhoon_years = []
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from jubatus.recommender import client
from jubatus.recommender import types

if __name__ == '__main__':

    recommender = client.recommender("127.0.0.1",9199)

    for i in range(0,943):
        sr = recommender.similar_row_from_id("movie_len", str(i) , 10);
        print "user ", str(i),  " is similar to :", sr
  
#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
from jubatus.recommender import client
from jubatus.recommender import types
import MySQLdb

if __name__ == "__main__":

    recommender = client.recommender("localhost",9199)

    # Analyze
    connector = MySQLdb.connect(host="localhost",db="jubatus_sample",user="******",passwd="")
    cursor = connector.cursor()
    cursor.execute("select * from plus_info_1")
    result = cursor.fetchall()

    list = []
    for row in result:
        userid = row[0]                            
        if userid not in list:
            print "============= Analyze"
            list.append(userid)

            sr = recommender.similar_row_from_id("", str(userid) , 3);
            print "user ", str(userid),  " is similar to :", sr

    cursor.close()
    connector.close()