My favorites | Sign in
Project Logo
          
Search
for
Updated Dec 28, 2008 by tsukue
Labels: Phase-Design
WebAPI  
web API 経由でデータを入出力するには / how to input or output data via web API

JP

基本のきまりごと

データの蓄積

ユーザがアイテムを選択したり評価をつけた場合に、以下のURLに対してGETリクエストを投げて下さい。成功時には空のレスポンス(204 NO CONTENT) が返ります。エラーの場合は 400系のレスポンス(たいてい 400 BAD REQUEST か 404 NOT FOUND) が返ります。

以下の3種類の操作が可能です。

「あるユーザがあるアイテムを選択した」

ユーザがあるアイテムを「clipした」とか「訪問した」というように、ユーザが明示的にレーティングを行わないタイプの場合はこのフォーマット。

  http://[base_url]/record?set=[セット名]&op=insert_pick&user_id=[ユーザid]&item_id=[アイテムid]

※ base_url は初期状態では http://localhost/cicindela です。

↓↑サービスの性質にあわせて、これか、下の「あるユーザがあるアイテムをに○点の評価をつけた」のどちらか一方のみを選択して使います。 ひとつの集計セットでratingsとpicks両方を使っても意味はありません。

「あるユーザがあるアイテムをに○点の評価をつけた」

ユーザが明示的に点数をつけるタイプの場合は以下のフォーマットを使う。rate は整数。

 http://[base_url]/record?set=[セット名]&op=insert_rating&user_id=[ユーザid]&item_id=[アイテムid]&rating=[評価]

「あるユーザがあるアイテムにあるタグをつけた」

タグベースのレコメンデーションを利用する場合は、以下のリクエストを利用する。(タグベースのレコメンデーションは、tag id を擬似的な user id に見立てて読み込むことで実現される。Demos, Examples などを参照のこと)

 http://[base_url]/record?set=[セット名]&op=insert_tag&user_id=[ユーザid]&item_id=[アイテムid]&tag_id=[タグid]

その他の各種データ操作

「あるアイテムをあるカテゴリに所属させる」

※カテゴリは、中身的にはタグとほとんど同じもの。ただし,以下の点でタグと異なる働きをします。

 http://[base_url]/record?set=[セット名]&op=set_category&item_id=[アイテムid]&category_id=[カテゴリid]

タグと同じような構造なので、ひとつのアイテムに複数のカテゴリを割り当ててもOK

「あるユーザがあるアイテムに[興味ありません]マークをつけた」

 http://[base_url]/record?set=[セット名]&op=insert_uninterested&user_id=[ユーザid]&item_id=[アイテムid]

セットしたデータを取り消す

 http://[base_url]/record?set=[セット名]&op=delete_pick&user_id=[ユーザid]&item_id=[アイテムid]

 http://[base_url]/record?set=[セット名]&op=delete_rating&user_id=[ユーザid]&item_id=[アイテムid]

 http://[base_url]/record?set=[セット名]&op=delete_tag&user_id=[ユーザid]&item_id=[アイテムid]&tag_id=[タグid]

 http://[base_url]/record?set=[セット名]&op=delete_uninterested&user_id=[ユーザid]&item_id=[アイテムid]

 http://[base_url]/record?set=[セット名]&op=remove_category&item_id=[アイテムid]&category_id=[カテゴリid]

レコメンデーション取得

レコメンデーションを取得するには、以下のURLに対してリクエストを投げてください。おすすめアイテムのidが、 関連の高い順に改行区切りテキスト形式で返されます。

特定アイテムに対するレコメンデーション(関連アイテム)取得 (=item to item)

関連アイテムのidをデフォルトで10件まで返します。

 http://[base_url]/recommend?set=[セット名]&op=for_item&item_id=[アイテムid]

特定ユーザに対するレコメンデーション取得 (=user to item)

指定したユーザに対するおすすめをデフォルトで20件まで返します。そのユーザがすでに選択済み(/評価済み) のアイテムはおすすめに含まれません。

 http://[base_url]/recommend?set=[セット名]&op=for_user&user_id=[ユーザid]

お隣ユーザ取得 (user to user)

指定したユーザに似たユーザをデフォルトで20件まで返します。

 http://[base_url]/recommend?set=[セット名]&op=similar_users&user_id=[ユーザid]

item to item / user to item / user to user に共通の決まりごと

上記のパラメータに加えて、以下をオプションで指定することができます。

レコメンダによっては、上記の三種類のレコメンデーションの一部をサポートしていないことがあります。その場合は常に空のセットが返ります。

例えば、アイテム同士の類似度マトリックスしかもっていないレコメンダの場合、user to user の結果を返すメソッドが用意されていないか、あってもパフォーマンスが著しく劣ることがあります。(レコメンダの仕組みについては WritingFilters あたりを参照して下さい。)

EN

Common rules

Accumulating data

Send a HTTP GET request each time a user selects an item, or rates an item. An empty response (204 NO CONTENT) is returned on success, 400 BAD REQUEST or 404 NOT FOUND on failure.

There are three basic accumulation requests.

An user has selected an item

Make this request each time an user has selected an item (added an item to the basket, clicked on a link, etc).

  http://[base_url]/record?set=[set name]&op=insert_pick&user_id=[user id]&item_id=[item id]

(base_url is http://localhost/cicindela by default.)

An user has given an item a rating of N

Make this request each time an user rates an item. Rating should also be an integer.

 http://[base_url]/record?set=[set name]&op=insert_rating&user_id=[user id]&item_id=[item id]&rating=[rating]

The above two operations, insert_pick and insert_rating can not co-exist in one set. Choose either of the two, depending on characteristics of the target service.

An user has tagged an item

Cicindela can make recommendations based on tags. Tag ids should also be integers. (Tag-based recommendation is achieved by assuming tag ids as pseudo user ids. No semantics are taken into concideration. See Demos and Examples for details)

 http://[base_url]/record?set=[set name]&op=insert_tag&user_id=[user id]&item_id=[item id]&tag_id=[tag id]

Other data manipulations

Associating an item to a category

Categories are not much different from tags, except for the following:

 http://[base_url]/record?set=[set name]&op=set_category&item_id=[item id]&category_id=[category id]

An item can belong to more than one categories.

An user is "not interested" in an item

 http://[base_url]/record?set=[set name]&op=insert_uninterested&user_id=[user id]&item_id=[item id]

Delete the informations set by the above calls

 http://[base_url]/record?set=[set name]&op=delete_pick&user_id=[user id]&item_id=[item id]

 http://[base_url]/record?set=[set name]&op=delete_rating&user_id=[user id]&item_id=[item id]

 http://[base_url]/record?set=[set name]&op=delete_tag&user_id=[user id]&item_id=[item id]&tag_id=[tag id]

 http://[base_url]/record?set=[set name]&op=delete_uninterested&user_id=[user id]&item_id=[item id]

 http://[base_url]/record?set=[set name]&op=remove_category&item_id=[item id]&category_id=[category id]

Getting recommendations

Make this request to retrieve a recommendation. A list of recommended ids are returned in the order of relevance, each separated by a new-line.

item-to-item recommendation

10 recommended item ids for the specified item are returned by default.

 http://[base_url]/recommend?set=[set name]&op=for_item&item_id=[item id]

user-to-item recommendation

20 recommended item ids for the specified user are returned by default. Items already selected (rated) by the user are excluded from the result.

 http://[base_url]/recommend?set=[set name]&op=for_user&user_id=[user id]

user-to-user recommendation

20 user ids similar to the specified user are returned by default.

 http://[base_url]/recommend?set=[set name]&op=similar_users&user_id=[user id]

rules common to all of the three recommendations

Optionally, following parameters may be available.

Some recommenders do not support all of the above three recommendations. An empty set is returned on such cases.

For example, a recommender which works only on an item-to-item similarity matrix does not have the user-to-user recommendation method implemeted, or, does not perform well even if it has. (See WritingFilters for more detailed information on recommenders.)


Sign in to add a comment
Hosted by Google Code