AIZU ONLINE JUDGE(AOJ)ã¨ãã競æããã°ã©ãã³ã°ã®åé¡ãå ¬éãã¦ãããµã¤ããããã
1年以ä¸åã«AOJãå°ãã ããã£ã¦ããé ã«ãAOJã®åé¡ãæ¨è¦ããã¹ã¯ãªãããæ¸ãããã®ã®ãç¹ã«å
¬éã使ç¨ãããã«æ¾ç½®ãã¦ããã®ã§ããã°è¨äºã«ãã¦ä¾é¤(ï¼)ãã¦ããã
AOJã«ã¯ããããã®åé¡ããã£ã¦ãã©ãã解ãã¹ããããããããªãã®ã§ãã¨ããããæ¨è¦ã·ã¹ãã ãä½ã£ã¦ã¿ã(ã¢ããã¼ã·ã§ã³ããããã
AOJではAPIが公開ããã¦ãã¦ãåã¦ã¼ã¶ã¼ãã©ã®åé¡ã解ãã¦ããããªã©ã®è²ã
ãªæ
å ±ãå¾ããã
ãã¢ã ã試ãããæ¹ã¯ãã¡ã
å¦çã®æ¦è¦
- AOJã®APIã使ã£ã¦åã¦ã¼ã¶ã¼ãã©ã®åé¡ã解ãã¦ãããã¨ãããã¼ã¿ãéããã
- éãããã¼ã¿ãå ã«å調ãã£ã«ã¿ãªã³ã°ãç¨ãã¦æ¨è¦ããã
ãã¼ã¿ã®åå¾
APIã®çµæã¯XMLã§è¿ãããã
ã»ã¨ãã©åé¡ã解ãã¦ããªãã¦ã¼ã¶ã¼ãé¤å»ããããã«ãä¸å®ä»¥ä¸ã®åé¡æ°ã解ãã¦ããã¦ã¼ã¶ã¼ã®ãªã¹ããåå¾ããã
å¾ããããªã¹ããå ã«ããããã®ã¦ã¼ã¶ã¼ã解ãã¦ããåé¡ã®ãªã¹ããåå¾ãã
以ä¸ã«ã¯ãã¼ã«ããæã®ã³ã¼ããè²¼ã£ã¦ããã
å¼æ°ã«ä¸ããæ°å¤ãããã¦ã¼ã¶ã¼ã®è§£ããåé¡æ°ãå°ãªãå ´åã¯åã£ã¦ããªãã
大äºãªãããã«ãã¦ã¼ã¶ã¼ãã¨ã«1ã2ç§ã®ã¹ãªã¼ããå
¥ãã¦ããAPIãå©ãã¦ããã
import xml.etree.ElementTree import urllib2 import sys import time import random argc = len(sys.argv) if argc != 2: sys.exit('Error: Invalid argument') try: min_user = int(sys.argv[1]) except: sys.exit('Error: Invalid argument') res = urllib2.urlopen('http://judge.u-aizu.ac.jp/onlinejudge/webservice/user_list?solved_min={}'.format(min_user)) if res.code != 200: sys.exit('Error: Invalid response') user_tree = xml.etree.ElementTree.fromstring(unicode(res.read(), errors = 'ignore')) for user in user_tree.iterfind('user'): user_id = user.findtext('id').replace(u'\n', u'') print user.findtext('name').replace(u'\n', u'').encode('utf-8', errors = 'ignore') print user_id.encode('utf-8', errors = 'ignore') res = urllib2.urlopen('http://judge.u-aizu.ac.jp/onlinejudge/webservice/solved_record?user_id={}'.format(user_id)) if res.code != 200: sys.exit('Error: Invalid response') solved_tree = xml.etree.ElementTree.fromstring(unicode(res.read(), errors = 'ignore')) for solved in solved_tree: print solved.findtext('problem_id').replace(u'\n', u'').encode('utf-8', errors = 'ignore'), print time.sleep(random.uniform(1, 2))
å調ãã£ã«ã¿ãªã³ã°
ããã¦ã¼ã¶ã¼ã«å¯¾ãã¦æ¨è¦ãããã¨ãã«ããã®ã¦ã¼ã¶ã¼ã«ä¼¼ãå¥ã®ã¦ã¼ã¶ã¼ã®æ
å ±ãå©ç¨ãã¦æ¨è¦ãè¡ãã¨ããææ³ã§ããã
ä»åã®ã¿ã¹ã¯ã§ã¯ãã©ã®åé¡ã解ãã¦ããããå
ã«æ¨è¦å¯¾è±¡ã®ã¦ã¼ã¶ã¼ã¨ä¼¼ã¦ããã¦ã¼ã¶ã¼ãä½äººãæ±ãã¦ãå¾ãããã¦ã¼ã¶ã¼ãå
±éãã¦è§£ãã¦ããåé¡ã®ä¸ããæ¨è¦å¯¾è±¡ã®ã¦ã¼ã¶ã¼ã解ãã¦ããªããã®ãæ¨è¦ããã
ãã ãæ¨è¦å¯¾è±¡ã®ã¦ã¼ã¶ã¼ã解ããåé¡ã®åç´ãªé¨åéåã§ããã¦ã¼ã¶ã¼ã¯ä¼¼ã¦ããã¦ã¼ã¶ã¼ãé¸ã¶ã¨ãã«åãé¤ãã
å調ãã£ã«ã¿ãªã³ã°ã®è©³ç´°ãç¥ãããæ¹ã¯ä»¥ä¸ã®PDFãããããã§ãã
ã¦ã¼ã¶ã¼ã®é¡ä¼¼åº¦
ã¦ã¼ã¶ã¼ãã¨ã«ããããã®åé¡ã解ãããã©ããã®ãã¯ãã«ãä½æããã¦ã¼ã¶ã¼ã©ããã®ã³ãµã¤ã³é¡ä¼¼åº¦ãæ±ããã
ãã ãããã¯ãã«ã®è¦ç´ ãåç´ã«åé¡ã解ãããã©ããã®äºå¤ã®ãã¯ãã«ã«ããã¨ç°¡åéããåé¡ãæ¨è¦ããã¦ãã¦ãã¾ãã¨ããæ¬ ç¹ããã
人æ°ãã¤ã¢ã¹
æ¨è¦ã·ã¹ãã ã«ã¯ã¿ããªã«å ±éãã¦äººæ°ãããã¢ã¤ãã ãæ¨è¦ããããå¾åãããã
ãæä¸æ¥æ¨¹ããã®èä½ã¯ãæ¥æ¬ã§ã¯èè¥ç·å¥³ãèªãã§ããããããã£ã¦ãã©ã®æ¬ãè¦ã¦ãæä¸ããã®æ¬ãæ¨è¦ããã¦ãã¾ãäºæ ã«ãªã£ãããONE PIECEããèªãã§ã人ã«ããããªã¼ã»ããã¿ã¼ããèªãã§ã人ã«ãã1Q84ããæ¨è¦ããã¦ãã¾ãã
楽天「ネット企業にとって“データを分析して活用すること”がビジネスのコア」~レコメンドの「村上春樹問題」からオープンソースを使ったデータ解析まで~ 【モバイル&ソーシャルWEEK2012レポート】 (1/2):MarkeZine(マーケジン)
ä»åã®ã¿ã¹ã¯ã®å ´åãã¿ããªãå ±éãã¦è§£ãã¦ããåé¡ï¼ç°¡åéããåé¡ãæ¨è¦ãã¦ãã¾ã
tf-idf
ã¿ããªãå ±éãã¦è§£ãã¦ããåé¡ï¼ç°¡åéããåé¡ãæ¨è¦ãããã®ãæå¶ãããããèªç¶è¨èªå¦çã§åèªãã¯ãã«ã使ãã¨ãã«tf-idfã¨ããååã§ç¥ããã¦ããæ¹æ³ã¨åæ§ã®å¦çãè¡ã£ãã
tf-idfã§ã¯åèªãããã¤ã®ææ¸ã«åºç¾ãããã¨ããææ¸é »åº¦ãæ±ãã¦ãææ¸å
ã§ã®åèªã®ç¸å¯¾é »åº¦ãææ¸é »åº¦ã®å¯¾æ°ã§å²ã£ã¦ããã
ãªãææ¸é »åº¦ã§å²ããã¨ããã¨ãå¤ãã®ææ¸ã«å
±éãã¦åºç¾ããåèªã¯ãã¾ãç¹å¾´çã§ãªããã¨ãå¤ãããã§ããã
ä»åã®ã¿ã¹ã¯ã§ã¯ããã¤ã®ã¦ã¼ã¶ã¼ã«åºç¾ãããã¨ããã¦ã¼ã¶ã¼é »åº¦ãæ±ãã¦ãåé¡ã®ç¸å¯¾é »åº¦ãåç´ã«ã¦ã¼ã¶ã¼é »åº¦ãã®ãã®ã§å²ããã¨ã«ããã
ä»ã«ãã¦ã¼ã¶ã¼é »åº¦ã®å¹³æ¹æ ¹ã対æ°ãªã©è²ã
ã¨è©¦ããããã¦ã¼ã¶ã¼é »åº¦ãã®ãã®ã§å²ã£ãã»ããä¸çªé¢ç½ã(éæ¿ãª)çµæãè¿ããã®ã§æ¡ç¨ããã
ã½ã¼ã¹ã³ã¼ã
å¼æ°ã«ã¦ã¼ã¶ã¼IDãæå®ãã¦ãä¸ã«è¼ããã¹ã¯ãªããã§ã¯ãã¼ã«ããçµæãæ¨æºå
¥åã«ä¸ãã¦ä½¿ãã
ãããã¿ã¤ãã§é©å½ã«ä½ã£ãã ããªã®ã§ã³ã¼ãã¯æ±ãã
ä¼¼ã¦ããã¨ã¿ãªãã¦ã¼ã¶ã¼æ°ãæ¨è¦ããæ°ãªã©ã®ãã©ã¡ã¼ã¿ã¯ãã¼ãã³ã¼ãããã¦ã
# -*- coding: utf-8 -*- import xml.etree.ElementTree import urllib2 import sys import time import math import collections uf = collections.Counter() def freq_iuf(p): return 1.0 / uf[p] freq = freq_iuf def cos(v1, v2): numerator = sum([freq(c) * freq(c) for c in v1 if c in v2]) square = lambda x: freq(x) * freq(x) denominator = math.sqrt(sum(map(square, v1)) * sum(map(square, v2))) return float(numerator) / denominator if denominator != 0 else 0 user = {} count = 0 for line in sys.stdin: line = line.strip() count += 1 if count == 2: id = line if count == 3: problem = set(line.split()) user[id] = problem for p in problem: uf[p] += 1 count = 0 argc = len(sys.argv) if argc != 2 or sys.argv[1] not in user: sys.exit('Error: Invalid argument') userid = sys.argv[1] u1 = userid p1 = user[userid] temp = [] for u2, p2 in user.iteritems(): if p1.issuperset(p2): continue sim = cos(p1, p2) temp.append((sim, u2, p2)) temp.sort() rec = collections.Counter() limit = 30 for sim, u2, p2 in reversed(temp): if limit < 0: break limit -= 1 for item in p2: if item not in p1: rec[item] += sim * freq(item) / len(p2) print u'ã¦ã¼ã¶ã¼ID:', u1 print u'ä¼¼ã¦ããã¦ã¼ã¶ã¼:', for sim, u2, p2 in reversed(temp[-5:]): print u2, print print u'æ¨è¦ãããåé¡:', for k, v in rec.most_common(5): print k, print
çµæã®ãã¢(éå»ã«ã¯ãã¼ã«ããéçãªçµæ)
ãã¼ã¿ãå
¨é¨JSONã«ãã¦ãã®è¨äºã«ç´æ¥åãè¾¼ãã§JavaScriptã§è¡¨ç¤ºãããã¨æã£ããã¯ã¦ãªããã°ã®è¨äºã«ã¯é·ãå¶éãããããã失æãã(´ã»Ïã»ï½)
ãããããªãã®ã§å¤é¨ã«ç½®ãã¦ããã¦iframeã§èªã¿è¾¼ã¿ã
ã¨ãããã自分のアカウント(mugenen)ã«å¯¾ãã¦æ¨è¦ããçµæãè²¼ã£ã¦ããã
éå»ã«ICPC(å½é大å¦å¯¾æããã°ã©ãã³ã°ã³ã³ãã¹ã)ã®åé¡ã解ãã¦ããã®ã§ãä¸ä½5件ãICPCé¢é£ã®åé¡ã¨ãªã£ã¦ãã¦ã¾ãã¾ãããçµæãå¾ããã¦ãã
解ãã¦ããã¦ã¼ã¶ã¼æ°ã§å²ã£ã¦ããã®ã§ããã¾ã人æ°ã®ãªãåé¡ãé£æ度ã®é«ãåé¡ã極端ã«åªå
ããã¦åºã¦ããã®ã§æ³¨æã
ã¾ã¨ã
è¤æ°äººãæå®ãã¦ãããã®ã¦ã¼ã¶ã¼ã«å¯¾ããæ¨è¦ã¨ããå®è£
ãããWebã¢ããªã¨ãã¦å
¬éããããã¨æã£ã¦ãããã©ã1年以ä¸æ¾ç½®ãã¦ãã¦ããæ°é
ããªãã£ãã®ã§ããã°ãã¿ã«ããã
æ¨è¦ã¦ã¼ã¶ã¼æ°ã¨ã¢ã¤ãã æ°ã¨ãå°ãªããã°ãåç´ã«ç·å½ãããã ãã§ç°¡åã«æ¨è¦ã·ã¹ãã ãä½ãã(20å以ä¸è§£ãã¦ããã¦ã¼ã¶ã¼ã ãã§æ°å人ã¨ãããã®ã§å
¨å¡ã«æ¨è¦ããã¨ããããéãã£ã)
æ å ±æ¨è¦ã·ã¹ãã å ¥é -çè«ã¨å®è·µ-
- ä½è : Dietmar Jannach,Markus Zanker,Alexander Felfernig,Gerhard Friedrich,ç°ä¸å å·±,è§è°·åä¿
- åºç社/ã¡ã¼ã«ã¼: å ±ç«åºç
- çºå£²æ¥: 2012/06/22
- ã¡ãã£ã¢: åè¡æ¬
- è³¼å ¥: 1人 ã¯ãªãã¯: 15å
- ãã®ååãå«ãããã° (1件) ãè¦ã