Skip to main content

Product2Vec model for finding complementary and fungible products

Project description

Python Version Code style: black License: MIT pipeline codecov

product2vec

product2vec is a Python library that implements Product2Vec model. It is capable of finding complements and substitutes among products given shopping baskets. Current implementation is based on the original paper: https://ssrn.com/abstract=3519358

Installation

pip install product2vec

Usage

>>> from product2vec import Product2Vec
>>> # toy dataset with two baskets and 4 products
>>> data = [
...     ['coffee', 'cookies', 'chocolate'],
...     ['tea', 'cookies', 'chocolate'],
... ]
>>> prod2vec = Product2Vec(vector_size=3, min_count=1, sample=0, seed=1, workers=1)
>>> _ = prod2vec.fit(data)
>>> prod2vec.show_substitutes(product='tea', topn=2)
[('coffee', 0.024425969), ('chocolate', 0.023691988)]
>>> prod2vec.show_complements(product='cookies', topn=2)
[('chocolate', 0.5030633), ('coffee', 0.5007087)]

Refer to usage_example.ipynb which can be found in GitHub repository for short model description and elaborate usage.

Contributing

If you spot any bugs or have suggestions don't hesitate to open an issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

product2vec-0.1.0.tar.gz (11.8 kB view hashes)

Uploaded Source

Built Distribution

product2vec-0.1.0-py3-none-any.whl (10.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page