MG

muhgalihhh

Back to Works

OptimizeRandomForestClassificationPerformanceonLungCancerDataImbalancewithSMOTEMethod

Data Science & AnalysisMachine Learning, Data Science & Analysis (Asignment) · Universitas Jenderal Soedirman
Python
Optimize Random Forest Classification Performance on Lung Cancer Data Imbalance with SMOTE Method screenshot 1

Overview

In medical data, the cases that matter most are often the rarest. This study tackles class imbalance in a lung cancer dataset using SMOTE (Synthetic Minority Over-sampling Technique) with a Random Forest classifier, and measures how much balancing the training data actually helps.

  • Context: Data Mining course research paper, Informatics, Universitas Jenderal Soedirman (June 2024)

  • Team: 3 people

  • Tools: Python

Dataset

A Kaggle lung cancer dataset with 309 records and 16 attributes: gender, age, 13 yes/no symptoms and risk factors (smoking, yellow fingers, anxiety, peer pressure, chronic disease, fatigue, allergy, wheezing, alcohol, coughing, shortness of breath, swallowing difficulty and chest pain) and the diagnosis label.

After removing duplicates, 276 records remained: 238 negative and only 38 positive, roughly a 6 to 1 imbalance.

Method

  1. Remove duplicate records

  2. Split the data 80:20 into training and test sets

  3. Apply SMOTE to the training data only, creating synthetic minority samples by interpolating between nearest neighbors

  4. Train Random Forest on both the original and the balanced training set

  5. Evaluate both models on the same untouched test set

Set

Minority class

Majority class

Training, original

26

194

Training, after SMOTE

194

194

Test, untouched

12

44

Results

Metric

Random Forest

Random Forest + SMOTE

Accuracy

87.5%

91.1%

Recall

88%

91%

Precision

87%

92%

F1-score

86%

90%

On the 56-record test set, SMOTE eliminated the only false positive (1 → 0) and caught one more true positive (6 → 7 out of 12).