Hardik Manish Runwal

Supervised learning · Evaluation

A reproducible XGBoost classification workflow

A structured classification pipeline exploring how validation, hyperparameter selection, and data preparation affect generalization.

View source on GitHub ↗

1. What problem were you solving?

I built this project to develop a systematic understanding of supervised classification using gradient-boosted decision trees.

My goal was to implement a complete machine-learning workflow rather than simply fit a classifier to a dataset. I wanted to understand how data preprocessing, feature engineering, model configuration, hyperparameter optimization, and evaluation interact to determine predictive performance.

XGBoost was a useful choice because gradient-boosted trees are effective on many structured-data problems and offer a range of controls over model complexity, regularization, and generalization.

The project focused on building a reproducible classification pipeline with explicit training and validation stages, systematic hyperparameter search, and quantitative performance evaluation.

2. What dataset did you use?

The project uses a dataset for supervised classification, but the exact dataset name and source need to be confirmed from the repository.

The details required for a reproducible description include:

  • Dataset source and collection method.
  • Number of samples and input features.
  • Target variable and class definitions.
  • Class distribution and potential imbalance.
  • Missing values, duplicates, and preprocessing requirements.
  • Any restrictions or assumptions associated with the data.

I would document these details before publishing a specific description of the classification problem. Without verifying the original data, I would not claim a particular dataset size, class balance, or feature set.

3. What was your complete pipeline?

The project follows a conventional supervised-learning workflow.

Data inspection and preparation: Load the structured dataset, inspect its dimensions, examine missing values, identify the target variable, and prepare the feature matrix and target labels.

Train/test separation: Split the dataset into training and held-out test sets. The earlier workflow used an 80/20 split with a fixed random seed and stratification for classification.

Model initialization: Configure an XGBClassifier as the baseline estimator.

Hyperparameter optimization: Use scikit-learn's GridSearchCV to evaluate candidate model configurations using five-fold cross-validation.

Model selection: Select a configuration using the chosen cross-validation scoring metric.

Final evaluation: Evaluate the selected model on the held-out test set using classification metrics and diagnostic outputs.

The principal technologies are Python, Pandas, NumPy, scikit-learn, and XGBoost.

The separation between cross-validation and held-out testing is important: the test set should remain outside the hyperparameter-selection process so that the final evaluation provides a less biased estimate of generalization performance.

4. What features did you engineer?

Feature engineering is an important part of a classification pipeline because the information and representation supplied to the model influence what it can learn.

The project included data preparation and feature-engineering work as part of the supervised-learning workflow.

However, the exact engineered features, transformations, categorical encodings, and reasons for selecting them need to be recovered from the implementation before I can describe them accurately.

For a rigorous implementation, transformations that learn parameters from data should be fitted using training data only, ideally through a scikit-learn pipeline. This prevents information from the validation or test data from influencing preprocessing.

I would document the actual transformations used rather than claim that scaling, categorical encoding, or particular domain-specific features were implemented without confirming them.

5. How did you use cross-validation?

The earlier project workflow used five-fold cross-validation through GridSearchCV.

The training data is divided into five folds. For each candidate hyperparameter configuration, the model is trained on four folds and evaluated on the remaining fold, repeating the process until each fold has served as the validation fold.

The validation scores are then aggregated to compare configurations.

For classification problems, stratified cross-validation is generally appropriate when maintaining class proportions across folds matters. Whether the final implementation explicitly used StratifiedKFold or relied on scikit-learn's default classifier cross-validation behavior should be verified in the code.

The workflow also used a separate held-out test set. This distinction matters because repeatedly selecting configurations against the test set would introduce evaluation leakage.

Any preprocessing that learns from the data should likewise be performed within each cross-validation fold rather than before the split.

6. What hyperparameters did you tune?

The earlier configuration notes identify a grid search over the following XGBoost parameters:

  • max_depth: Controls the maximum depth of individual trees.
  • learning_rate: Controls the contribution of each boosting iteration.
  • n_estimators: Specifies the number of boosting rounds.
  • subsample: Controls the proportion of training examples sampled for each tree.

These parameters affect the trade-off between model complexity, learning speed, and generalization.

The project used GridSearchCV to compare candidate configurations systematically rather than relying entirely on manual trial and error.

The exact parameter values, search-grid size, selected configuration, and final cross-validation score should be reported from the original code and results. The earlier notes also described balanced accuracy as a model-selection metric, but the actual scoring configuration should be verified before being stated as a confirmed result.

7. What were the results?

My CV reports a 91% F1 score on held-out test data.

F1 is the harmonic mean of precision and recall:

\[ F_1=2\frac{\text{Precision}\cdot\text{Recall}} {\text{Precision}+\text{Recall}} \]

However, the interpretation of this result depends on how F1 was calculated. For binary classification, it may refer to the positive class; for multiclass classification, it could refer to macro, weighted, or micro F1.

Before publishing the result, I would verify the metric definition, class labels, held-out test configuration, and evaluation output. I would also check whether the reported 91% came from the final held-out evaluation or from cross-validation.

A useful results table would include F1, precision, recall, balanced accuracy, and a confusion matrix, alongside the baseline model's performance. This would help demonstrate whether the classifier performs consistently across classes rather than relying on a single aggregate score.

The exact baseline scores and the improvement attributable to hyperparameter tuning have not yet been established from the available project records.

8. What did you learn from the experiments?

The project reinforced the importance of evaluating the entire machine-learning workflow rather than focusing exclusively on the classifier.

Several lessons are particularly relevant:

Validation design matters: Cross-validation provides a more systematic basis for comparing hyperparameters than relying on a single training run.

Model complexity needs to be controlled: Tree depth, learning rate, and the number of estimators interact, so tuning them requires attention to both predictive performance and overfitting.

Metrics answer different questions: F1 summarizes the precision–recall trade-off, while balanced accuracy helps assess performance across classes. A confusion matrix provides more detail about the errors being made.

Reproducibility is essential: Fixed random seeds, documented configurations, and a separate test set make experimental results easier to reproduce and interpret.

A more complete analysis would also examine feature importance, compare training and validation performance, and investigate misclassified examples. The precise findings from those analyses should be reported only if the corresponding experiments were performed.

9. What would you improve?

If I extended the project, I would focus on strengthening the experimental methodology and making the results easier to interpret.

  1. Reproducible preprocessing: Put data transformations and the estimator into a scikit-learn pipeline to avoid leakage during cross-validation.
  2. Stronger baselines: Compare XGBoost with simpler models such as logistic regression and random forests, using the same splits and metrics.
  3. More robust validation: Evaluate variability across folds and, where appropriate, across multiple random seeds.
  4. Error analysis: Examine the confusion matrix and representative false positives and false negatives to understand systematic failure modes.
  5. Feature interpretation: Analyze feature importance and, if appropriate, use SHAP values to investigate how features influence predictions.
  6. Calibration: Evaluate whether predicted probabilities correspond to observed outcome frequencies if the application requires reliable confidence estimates.
  7. Robustness checks: Investigate sensitivity to class imbalance, missing values, and changes in the data distribution.

These improvements would help move the project from a functional classification pipeline toward a more rigorous and interpretable evaluation framework.

10. Where can people see the work?

GitHub repository: https://github.com/HardikLovesTech/XGBoost

The repository is the primary artifact for inspecting the implementation.

For the portfolio, I would include:

  • The data-processing and training workflow.
  • The hyperparameter-search configuration.
  • A results table showing baseline and tuned performance.
  • A confusion matrix and classification report.
  • Feature-importance visualizations, if available.
  • A short explanation of the cross-validation and held-out testing strategy.

The central contribution of the project is a structured approach to supervised classification, combining preprocessing, model selection, cross-validation, and evaluation in a reproducible workflow.