====== Personalization ======
Recommendations based on customer history.
===== git =====
https://git.picalike.corpex-kunden.de/picalike/personalization
working version is in master branch
===== Database =====
host: **sandy.picalike.corpex-kunden.de**\\
database: **you_api**
=== collections ===
**shops** gmm and product quantization lookup table for each shop\\
**products** pq vector and image url for each product\\
**customers** fisher vector, purchased products, recommendations and info about the customers
===== Fisher vectors and product quantization =====
A visual vocabulary consisting of all the products from the feed is learned using a mixture of gaussians. The results are saved in the shops collection. The visual vocabulary quantizes the feature space into different cells, and image features are soft-assigned to these cells. The assignments are then aggregated over the images of all the purchased products to obtain a customer representation.
The fisher vector is calculated as follows: for each product we take its features from the feature_db and compute the gradient of the log-likelihood of the image wrt the mixing weight, the mean and the covariance (using diagonal covariance matrices). By averaging the gradients over all products, this yields a customer descriptor of size K(1 + 2d), where d is the dimension of the feature space and K is the number of gaussians. The vector is then normalized and saved in the customer collection.
In order to speed up the search for recommended products, we apply product quantization to the products' fisher vectors. The product quantization is learned over all products in the feed and the lookup table is saved in the shops collection.
The asymmetric distance between the customer's fisher vector and the pq vectors of the products returned by a given solr query is calculated and weighted according to gender and categories. The nearest products are saved in the customer collection together with the query and returned by the API.
===== API =====
[no running service]
=== /add_checkouts ===
input: {"s_id": , "c_id": , "p_list": ["prod_ids": [], "date": ]}
output: "checkout added"
add new checkout to customer history
=== /add_images ===
input: {"s_id": , "c_id": , "p_list": []}
output: "images added"
add images of products to customer history (free products too)
=== /update_cfv ===
input: {"s_id": , "c_id": , "start_date": , "gmm_name": }
output: []
calculate fisher vector for customer using products purchased starting from ''%%start_date%%'' until now
=== /update_pqs ===
input: {"s_id": , "gmm_name": , "q": }
output: "pq for products"
calculate product quantization code for products in the query result
=== /get_recommended ===
input: {"s_id": , "c_id": , "q": , 'n_res': , "gmm_name": }
output: []
get recommended products by query or – if recommendations do not exist yet – match given customer with products returned by the query
=== /match ===
input: {“s_id”: , “c_id”: , “q”: , 'n_res': , “gmm_name”: }
output: []
match given customer with products returned by the query