BaşlayınÜcretsiz Başlayın

Alternative segmentation with NMF

In this exercise, you will analyze product purchase data and identify meaningful segments using non-negative matrix factorization algorithm (NMF). It works well with sparse customer by product matrices that are typical in the e-commerce or retail space. Finally, you will extract the components that you will then explore in the upcoming exercise.

We have loaded pandas as pd and numpy as np. Also, the raw customer by product purchase dataset has been loaded as wholesale.

Bu egzersiz

Machine Learning for Marketing in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Import the non-negative matrix factorization function from sklearn.decomposition.
  • Initialize NMF instance with 4 components.
  • Fit the model on the wholesale sales data.
  • Extract and store the components as a pandas DataFrame.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import the non-negative matrix factorization module
from sklearn.decomposition import ___

# Initialize NMF instance with 4 components
nmf = ___(4)

# Fit the model on the wholesale sales data
nmf.___(wholesale)

# Extract the components 
components = pd.DataFrame(data=nmf.___, columns=wholesale.columns)
Kodu Düzenle ve Çalıştır