Skip to content

Instantly share code, notes, and snippets.

import numpy as np
# Product ID to generate recommendations for - You could try different product IDs in the data such as A16, C17, P12 etc.
product_id = "A13"
# Get Vector (Embedding) array of the given product
vector_array = np.array(product_ids_and_vectors[product_ids_and_vectors["Product_ID"]==product_id]["Vectors"].tolist())
# Get cluster number for the given product assigned by the model
cluster_no = model.predict(vector_array)[0]