File size: 2,411 Bytes
62a4259
 
 
 
14d918c
62a4259
 
14d918c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62a4259
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
tags:
- model_hub_mixin
- pytorch_model_hub_mixin
license: mit
---

# CustomerSegmentationModel: Autoencoder for Customer Segmentation

## Model Details

- **Model Architecture:** Autoencoder  
- **Framework:** PyTorch  
- **Input Dimension:** User-defined (`input_dim`)  
- **Output:** Reconstructed customer features  
- **Dataset:** [Predicting Credit Card Customer Attrition](https://www.kaggle.com/datasets/thedevastator/predicting-credit-card-customer-attrition-with-m)  

## Model Description

The **CustomerSegmentationModel** is an **autoencoder** designed to extract low-dimensional representations of customer data. It consists of:
- An **encoder** that compresses the input into a **2D latent space**.
- A **decoder** that reconstructs the original input from the compressed representation.

This approach enables **customer segmentation** based on the learned latent space.

## Training Details

- **Loss Function:** Smooth L1 Loss  
- **Optimizer:** Adam  
- **Batch Size:** 256  
- **Number of Epochs:** 100  
- **Regularization:** Dropout (50%) and Layer Normalization  

### Model Architecture

```python
class CustomerSegmentationModel(nn.Module, PyTorchModelHubMixin):
    def __init__(self, input_dim):
        super(CustomerSegmentationModel, self).__init__()
        self.encoder = nn.Sequential(
            nn.Linear(input_dim, 256),
            nn.ReLU(),
            nn.Dropout(0.5),
            nn.Linear(256, 128),
            nn.ReLU(),
            nn.Dropout(0.5),
            nn.LayerNorm(128),
            nn.Linear(128, 64),
            nn.ReLU(),
            nn.Dropout(0.5),
            nn.LayerNorm(64),
            nn.Linear(64, 2),
        )
        self.decoder = nn.Sequential(
            nn.Linear(2, 64),
            nn.ReLU(),
            nn.Dropout(0.5),
            nn.Linear(64, 128),
            nn.ReLU(),
            nn.Dropout(0.5),
            nn.Linear(128, 256),
            nn.ReLU(),
            nn.Dropout(0.5),
            nn.Linear(256, input_dim),
            nn.Sigmoid(),
        )

    def forward(self, x):
        x = self.encoder(x)
        x = self.decoder(x)
        return x


This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
- Library: [More Information Needed]
- Docs: [More Information Needed]