CHAPTER 1

Getting Started

Welcome to bestPy! In this opening chapter, we will do a minimal setup to arrive at a recommendation quickly, just to wet your appetite.

Preliminaries

We only need this because the examples folder is a subdirectory of the bestPy package.


In [1]:
import sys
sys.path.append('../..')

Minimal imports


In [2]:
from bestPy import RecoBasedOn
from bestPy.datastructures import Transactions

Read data

Specify your own data file or play with the examples file


In [3]:
file = '../tests/data/data50.csv'  # Enter the path to and name of your data file here!
data = Transactions.from_csv(file)

Recommend articles

Specify below the ID of the customer you want to make recommendations for


In [4]:
customer = '7'  # Specify the ID of the customer you want to make recommendations for here!

recommendation = RecoBasedOn(data)
top_five = recommendation.for_one(customer)

for article in top_five:
    print(article)


MO717EL52ARFALID-447
AC016EL67BJWALID-932
PI794EL32ENZALID-3067
VI962EL59EFGALID-2840
MO717EL47ARKALID-452

That wasn't too hard, now, was it?


In [ ]: