March 2019
Beginner to intermediate
464 pages
10h 57m
English
The data we have now represents individual items purchased by customers. However, in order to build a product recommendation system with a collaborative filtering algorithm, we need to have data where each record contains information on which item each customer has bought. In this section, we are going to transform the data into a customer-item matrix, where each row represents a customer and the columns correspond to different products.
Let's take a look at the following code:
customer_item_matrix = df.pivot_table( index='CustomerID', columns='StockCode', values='Quantity', aggfunc='sum')
As you can see from this code snippet, we are using the pivot_table function to transform our data into a customer-item ...
Read now
Unlock full access