import numpy as np from sklearn.cluster import KMeans import matplotlib.pyplot as plt # Sample data: customer_id, total_purchases, avg_time_between_purchases (hours) customer_data = np.array([ [1, 25, 0.5], [2, 10, 5], [3, 15, 2], [4, 30, 1], [5, 7, 10], [6, 20, 3], [7, 12, 7], [8, 28, 0.8], [9, 6, 12], [10, 18, 1.5] ]) # Extract customer IDs and feature data customer_ids = customer_data[:, 0].astype(int) features = customer_data[:, 1:] # Perform k-means clustering n_clusters = 2 kmeans = KMeans(n_clusters=n_clusters, random_state=42) cluster_labels = kmeans.fit_predict(features) # Find the cluster with the lowest average time between purchases impulsive_cluster = np.argmin(kmeans.cluster_centers_[:, 1]) # Get the customer IDs in the impulsive cluster impulsive_buyers = customer_ids[cluster_labels == impulsive_cluster] print("Impulsive buyers:", impulsive_buyers) # Visualize the clustering results (optional) plt.scatter(features[:, 0], features[:, 1], c=cluster_labels, cmap='viridis') plt.scatter(kmeans.cluster_centers_[:, 0], kmeans.cluster_centers_[:, 1], c='red', marker='x') plt.xlabel('Total Purchases') plt.ylabel('Average Time Between Purchases (hours)') plt.show()
top of page

SAMPLE. Blue Flannel

0004
$29.95
In stock
1
Product Details

Stay warm before and after those early morning surf sessions with this classic cotton flannel. This shirt features two front pockets with button closures, an asymmetrical yoke for unique styling across the back, and plenty of shoulder room for comfort.

Stylish and functional this is an essential piece for every closet. Available for purchase through SurfRide.

Material: 100% cotton
Color: Blue
Print: Plaid
Fit: Classic

Save this product for later
bottom of page