논문리뷰

[논문리뷰] SOS: Score-based Oversampling for Tabular Data (2/2)

매쓰도윤 2023. 7. 21. 10:40

3. Proposed Method

Definition 3.1. $\mathcal{T}$가 $M$개의 class $\{\mathcal{C}_m\}_{m=1}^M$을 갖는 table이라 하자. 이때 maximum cardinality보다 작은 cardinality를 갖는 $\mathcal{C}_j$, 즉 $|\mathcal{C}_j|<\max_m |\mathcal{C}_m|$인 $\mathcal{C}_j$를 minor class라고 정의한다. 따라서 일반적으로 $\mathcal{T}$는 one major class와 multiple minor classes를 갖는다. 우리의 목표는 minor classes에 $|\mathcal{C}_j|=\max_m |\mathcal{C}_m|$이 될 때까지 artificial fake minor record를 추가하여 oversampling하는 것이다.

 

3.1. Overall Workflow

score-based oversampling의 과정을 그림으로 나타내면 Fig.3과 같고, 이를 정리하면 다음과 같다.

(1) 각 class $\mathcal{C}_m$에 대해 score-based generative model을 학습시켜 $\mathcal{C}_m$의 trained score network $S_{\theta_m}$을 구한다.

(2) oversample해야 하는 minor class, 즉 target class $\mathcal{C}_j$에 대해 Fig.1(c)에서의 방법대로 $S_{\theta_j}$를 fine-tuning한다.

(3) target class $\mathcal{C}_j$를 oversampling하기 위해 Fig.3의 두 가지 option 중 하나를 선택하여 $|\mathcal{C}_j|=\max_m |\mathcal{C}_m|$이 될 때까지 반복한다.

    (a) $\mathcal{C}_j$를 제외한non-target class로부터 noisy vector를 추출하고 $S_{\theta_j}$를 이용하여 $\mathcal{C}_j$의 fake target record를 합성한다. (Fig.3(a)) 

    (b) noisy vector $\mathbf{z} \sim \mathcal{N}(\mu, \sigma^2)$을 샘플링하여 fake target record를 생성한다. (Fig.3(b))

(4) target class $\mathcal{C}_j$의 fake record를 생성했다면 Fig.2(b)의 Langevin corrector를 적용할 수 있다. 이 단계는 SGM의 type에 따라 선택적으로 생략할 수도 있다.

 

Figure 3 Diagram showing our model architectures.

 

Definition 3.2. $\mathcal{C}_j$가 oversampling해야 하는 target minor class일 때, $\mathbf{x}_0^- \in \mathcal{C}_j$는 target class의 target record이다.

 

Definition 3.3. $\mathcal{C}_j$가 oversampling해야 하는 target minor class일 때, $\mathbf{x}_0^+ \in \mathcal{C}_i$ ($i \neq j$)는 다른 non-target class의 record를 의미한다. binary classification의 경우 $\mathcal{C}_j$는 minor class이고 $\mathcal{C}_i$는 major class인 것이다. 표기의 편의성을 위해 '+'가 non-target class를 나타낸다고 정의할 것이다.

 

이 과정에서 주목해야 하는 부분은 i) 각 class $\mathcal{C}_m$에 대해 score network $S_{\theta_m}$을 design하는 것과 ii) fine-tuning method를 design하는 것이다.

 

Option 1 vs. Option 2: Fig.3은 noisy vector를 샘플링하는 두 가지 옵션을 보여주고 있다. Fig.3(a)에서는 non-target class의 $\mathbf{x}_0^+$를 변환하여 $\hat{\mathbf{x}}_0^-$를 생성하는데, 이 전략은 oversampling around class boundary라고 할 수 있다. Fig.3(b)에서는 random noisy vector로부터 샘플링하기 때문에 $\hat{\mathbf{x}}_0^-$가 class boundary 근처에 있다는 것을 보장할 수 없다.

 

첫 번째 option의 또 다른 장점은 $\mathbf{x}_T^+$가 Gaussian distribution이어야 한다는 조건이 필요 없다는 것이다. $\mathbf{x}_T^+$의 분포와 무관하게 우리는 $S_{\theta_-}$의 reverse SDE로 $\hat{\mathbf{x}}_0^-$를 얻을 수 있다. 따라서 $T$의 값을 자유롭게 선택할 수 있고, 이는 $T$ 값이 커질수록 계산량이 많아진다는 문제점을 해결한다는 장점을 갖는다. 두 번째 option의 경우에도 작은 $T$ 값에 대해 잘 작동한다는 사실을 찾아냈다. 첫 번째와 두 번째 option의 관계는 B-SMOTE와 SMOTE의 관계와 비슷하다고 정리할 수 있다.

 

3.2. Score-based Model for Tabular Data

우리는 Eq (1)과 (2)의 forward / reverse SDE를 사용한다. 앞에서 언급한 것처럼 SGM은 Eq (1)과 (2)의 $f$와 $g$의 type에 따라 세 가지 타입으로 구분된다. 본래 score network는 이미지를 처리하기 위한 용도이기 때문에 이를 tabular data synthesis model로 redesign해줘야 한다. 하지만 우리는 original design에서의 denoising score matching loss를 이용하여 score network를 학습시켰다.

 

우리의 방법은 $\mathcal{C}_j$를 oversampling하는 두 가지 옵션을 제시한다. 첫 번째 옵션은 i) $\mathcal{C}_i (i \neq j)$에서 $\mathbf{x}_0^+$를 선택하고 ii) forward SDE를 통해 noisy vector를 얻어서 iii) noisy vector를 fake target record로 변환시키는 과정의 style transfer-based architecture를 사용하는 것이다. 이 경우 $\mathbf{x}_T^+$는 original record $\mathbf{x}_0^+ \in \mathcal{C}_i$의 정보를 갖고 있으므로 $\mathcal{C}_j$의 fake target record를 효과적으로 생성할 수 있다. 따라서 이 option은 oversampling around class boundary라고 할 수 있는 것이다.

 

두 번째 옵션은 $\mathbf{z} \sim \mathcal{N}(\mu, \sigma^2)$을 샘플링하고 standard SGM을 사용하여 fake target record를 생성하는 것이다. 이때 Gaussian distribution $\mathcal{N}(\mu, \sigma^2)$는 SDE의 type에 따라 다음과 같이 정의된다.

 

 

3.3. Fine-tuning Method

score network $\{S_{\theta_m}\}_{m=1}^M$이 학습되면 모든 target class에 대해 fake record를 샘플링할 수 있지만, tabular data의 경우 샘플링 퀄리티를 향상시키기 위해 class information을 사용하여 fine-tuning하는 과정을 거쳐야 한다. $\mathcal{C}_j$를 fine-tuning하는 과정은 다음과 같다.

(1) time $t$와 $\mathbf{x}_t$가 주어졌을 때, score network $S_{\theta_m}$으로 계산한 log probability의 gradient는 다음과 같다. 이때 우리의 목표는 $(\mathbf{x}_t, t)$ 근처에서 모델을 fine-tuning하는 것이다.

 

(2) 그 다음, $i \neq j$일 때 $\mathbf{g}_{\mathbf{x}, t}^j$와 $\mathbf{g}_{\mathbf{x}, t}^i$ 사이의 각을 비교한다. 이때 두 벡터 사이의 각인 $\arccos \Big( \frac{\mathbf{g}_{\mathbf{x}, t}^j \cdot \mathbf{g}_{\mathbf{x}, t}^i}{||\mathbf{g}_{\mathbf{x}, t}^j|| ||\mathbf{g}_{\mathbf{x}, t}^i||} \Big)$가 충분히 크다고 가정하는데, 이는 $\mathcal{C}_j$와 $\mathcal{C}_i$가 $(\mathbf{x}, t)$ 근처에서 잘 분리되어 있다는 것을 의미한다. 그러나 이 각이 작아 두 벡터의 방향이 비슷할 때 문제가 발생할 수 있는데, 이때 $S_{\theta_j}$의 gradient를 fine-tuning하기 위해 다음의 loss를 사용한다.

 

제안된 fine-tuning method는 $(\mathbf{x}_t, t)$에서 gradient의 크기를 $w$에 따라 감소시킴으로써 reverse SDE process가 target and non-target class record가 Fig.4의 gray region으로 너무 많이 이동하는 것을 방지할 수 있다. 이때 damping coefficient $w$를 제어함으로써 방향을 조절할 수 있다.

 

Figure 4 Fine-tuning $\theta_j$ for class $\mathcal{C}_j$.

 

3.4. Training Algorithm

Algorithm 1은 전체적인 훈련 과정을 보여주고 있다. 처음에는 모든 $m$에 대해 score network parameter를 초기화하고, 그 다음 Line 3에서 $\mathcal{C}_m$을 이용하여 score network $S_{\theta_m}$을 학습시킨다. 여기서 Eq (3)의 standard denoising score matching loss를 사용하고, 이 단계가 끝나면 fake target record를 생성할 수 있다. 그 다음으로는 Line 7에서 score network를 향상시키는 과정이 진행된다. 그리고 마지막으로 Fig.3의 두 가지 옵션인 i) oversampling around class boundary 혹은 ii) regular oversampling 중 하나를 사용하여 $\mathcal{C}_j$를 oversampling하면 된다.

 

 

4. Experiments

실험 설정값과 결과에 대해 설명한다.


4.1. Experimental Environments

4.1.1. Datasets: tabular dataset을 사용했으며, 4개의 binary dataset과 2개의 multiple dataset을 사용했다. binary classification의 경우 Default, Shoppers, Surgical, WeatherAUS를 사용했으며 multi-class classification의 경우 Buddy와 Satimage를 사용했다.

 

4.1.2. Baselines: SMOTE, B-SMOTE, Adasyn, MedGAN, VEEGAN, TableGAN, CTGAN, TVAE, BAGAN, OCT-GAN으로 총 10개의 baseline을 사용하여 비교하였다.

 

4.1.3. Hyperparameters: 다양한 값의 hyperparameter를 설정하여 사용했다.

 

4.1.4. Evaluation Methods: augmented training data에 대해 Decision Tree, Logistic Regression, AdaBoost, MLP 등의 classification algorithm을 적용하여 훈련시켰고, testing data가 imbalanced이므로 weighted F1 score를 측정하였다. 또한 original and fake record를 histogram과 t-SNE로 표현하여 visualize했다.

 

4.2. Experimental Results

Table 2는 실험 결과를 정리한 것이다. 다른 baseline과 비교했을 때 SOS 모델이 더욱 좋은 성능을 보여준다는 것을 확인할 수 있다.

 

Table 2: Experimental results.

 

4.3. Sensitivity on Hyperparameters

Table 3는 hyperparameter를 변화시키면서 실험을 진행했을 때의 결과를 정리한 것이다. 이 실험을 통해 hyperparameter의 값을 어떻게 설정해야 가장 효과적인지 파악할 수 있었다.

 

Table 3: Results by some selected key hyperparameters

 

4.4. Sensitivity on Boundary vs. Regular Oversampling

Table 4는 Fig.3의 두 가지 option에 대한 실험 결과를 정리한 것이다. 큰 차이가 드러나지는 않지만 많은 경우에서 boundary oversampling이 더 좋은 결과를 나타낸다는 것을 확인할 수 있다.

 

Table 4: Comparison between the boundary vs. regular oversampling

 

4.5. Ablation study of the reverse SDE solver (or predictor)

Eq (2)에서 $\mathbf{x}_T^+$로부터 $\hat{\mathbf{x}}_0^-$를 구하기 위해 다양한 전략을 사용할 수 있다. 보편적으로는 Euler-Maruyama (EM) method가 사용되지만, 그 외에도 ancestral sampling, reverse diffusion, probability flow와 같은 SDE solver를 사용할 수도 있다. Table 5는 SDE solver를 다르게 했을 때 얻어진 결과를 정리한 것으로, Surgical dataset에서는 Euler-Maruyama method가 가장 좋은 성능을 보였으나 Shopper dataset에서는 ancestral sampling method가 더 좋은 성능을 보인 것을 확인할 수 있다. 이로 인해 predictor는 데이터셋에 의존한다는 결론을 내릴 수 있었다.

 

Table 5: Results by the revere SDE solver.

 

4.6. Ablation study on Adversarial Score Matching vs. Fine-tuning

Talbe 6은 Fig.2에서의 adversarial score matching과 fine-tuning의 효과를 비교한 결과를 정리한 것이다. 이때 거의 모든 케이스에서 fine-tuning 모델의 성능이 더욱 좋은 것을 확인할 수 있었다.

 

Table 6: Results of No Fine-tuning vs. Adversarial SGM vs. Fine-tuning

 

4.7. Visualization

4.7.1. Column-wise Histogram: Fig.5는 두 가지 histogram figure를 보여주고 있다. real histogram과 CTGAN histogram은 다소 다른 분포를 보이는 반면, SOS histogram은 비슷한 분포를 가진다는 것을 확인할 수 있다.  

 

Figure 5 Column-wise Histogram

 

4.7.2. t-SNE plot of fake/real records: Fig.6은 WeatherAUS dataset에서 real / fake record를 도식화한 그림이다. 반투명한 점이 real record이고, 선명한 점이 fake record를 나타낸다. 또한 화살표는 non-target record로부터 만들어진 target record를 연결한 것이다. 그림을 보면 fake record가 적절히 잘 생성된 것을 확인할 수 있다.

 

Figure 6 t-SNE plot of real/fake records by our method.

 

5. Conclusions & Limitations

minor class를 oversampling하는 문제는 데이터마이닝과 기계학습에서 오랫동안 연구되어 온 문제이다. 지금까지 여러 가지 다양한 방법들이 제안되었고, 본 논문에서는 Score-based oversampling method, SOS라는 방법을 제안하였다. 이미지를 위해 개발된 SGM을 기반으로 하였지만 여러 부분들을 재설계하였다. 6개의 dataset과 10개의 baseline으로 수행한 실험에서 우리의 방법은 모든 경우에 다른 oversampling method보다 우수한 성능을 보였으며 높은 F1 score를 얻을 수 있었다. 본 연구를 통해 minor class의 oversampling 분야에서 큰 발전을 이룰 수 있었다고 생각한다. SGM은 일반적으로 성능이 우수하지만, tabular data 생성 분야에서는 아직 초기 단계에 머물고 있다. 이번 연구가 더 많은 후속 연구를 이끌어낼 수 있기를 기대한다.

 

 

총평: M2m (Major to minor translation)과 SGM (score-based generative model)을 결합시킨 내용의 논문이다. 각각의 개념은 대충 이해를 했는데 두 내용을 결합시키니까 이해하기가 힘들었다. 사실 아직도 이해가 안 되는 부분이 많다... 이번에 매칭된 사수 분에게 논문의 내용을 reproduce해보는 과제를 받았는데, 아무래도 직접 코딩을 해보면서 이해하는 게 가장 좋을 것 같다. 이번 주말에는 논문을 읽기보다는 파이토치로 코딩하는 연습을 좀 많이 해봐야겠다.