Technical case study
Breast Cancer Classification: Multi-Algorithm Comparison
A comparative medical-classification exercise using multiple algorithms, standardised cellular features and confusion-matrix analysis.
The problem
This project implemented and compared six different machine learning classification algorithms to predict breast cancer diagnosis (malignant vs benign) based on cellular characteristics. I built a comprehensive medical classification pipeline using multiple algorithms to identify the most effective approach for cancer detection and diagnosis support.
How do common classifiers differ when they are evaluated on the same breast-cancer diagnostic dataset and preprocessing pipeline?
Approach
Rather than presenting the project as a notebook dump, this case study focuses on the decisions that shaped the analysis.
- Load & inspect data: Loaded breast cancer dataset using pd.read_csv() and separated cellular features (X) from diagnosis labels (y) using iloc[:, :-1] and iloc[:, -1] respectively, ensuring proper handling of medical diagnostic data.
- Train-test stratification: Applied train_test_split() with 75-25 split ( test_size=0.25 ) and fixed random state for reproducible medical model evaluation, crucial for healthcare applications.
- Feature standardization: Implemented StandardScaler() using fit_transform() on training data and transform() on test data to normalize cellular measurements across different scales without data leakage.
- Logistic Regression: Built a LogisticRegression(random_state=0) model as the statistical baseline for binary medical classification, providing interpretable probability outputs for clinical decision-making.
- Support Vector Machine (Linear): Implemented SVC(kernel=‘linear’) to find optimal linear decision boundaries for separating malignant from benign cases using maximum margin principles.
- Decision Tree Classification: Applied DecisionTreeClassifier(criterion=‘entropy’) to create interpretable rule-based diagnostic pathways that clinicians can follow and understand.
- K-Nearest Neighbors: Used KNeighborsClassifier(n_neighbors=5, metric=‘minkowski’, p=2) to classify cases based on similarity to neighboring data points, leveraging local patterns in cellular characteristics.
Key implementation decision
Keep preprocessing fixed so the model comparison is meaningful
Every classifier sees the same train/test split and standardised feature representation. That makes differences in predictions easier to attribute to the model rather than to inconsistent preprocessing.
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.25, random_state=0
)
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)
classifier = DecisionTreeClassifier(criterion="entropy", random_state=0)
classifier.fit(X_train, y_train)
y_pred = classifier.predict(X_test)
cm = confusion_matrix(y_test, y_pred)
Results & evidence
The figures below are the project evidence I would show first. The full implementation remains available through the GitHub link at the top of the page.
What challenged me
Working with medical diagnostic data presented a critical class imbalance consideration that required careful attention to evaluation metrics beyond simple accuracy. While accuracy score provides an overall performance measure, it can be misleading in medical contexts where false negatives (missing actual cancer cases) have far more severe consequences than false positives (flagging benign cases as suspicious). The challenge was ensuring that model evaluation properly weighted the clinical importance of sensitivity (recall) versus specificity, as a model with 95% accuracy might still miss 20% of actual cancer cases if the dataset is imbalanced. This was addressed by implementing confusion matrix analysis to examine true positives, false positives, true negatives, and false negatives separately, enabling assessment of each model’s ability to minimize the most clinically dangerous errors while maintaining overall diagnostic reliability.
What I learned
- A fair model comparison requires a shared split and preprocessing path.
- For medical classification, confusion-matrix errors are more informative than accuracy alone because different mistakes have different consequences.
- Standardisation is particularly important for distance- and margin-based classifiers when cellular features use different scales.
What I would improve next
- Use stratified cross-validation rather than relying on one split.
- Report sensitivity, specificity, precision, recall and ROC-AUC consistently across every model.
- Add probability calibration if the models are to be interpreted as decision-support tools.
In a diagnostic setting, a headline accuracy value can hide clinically important error patterns. The comparison therefore becomes more useful when false positives and false negatives are visible rather than collapsed into a single score.