Series Data Voyage Training Log

~1 min read

First Classification Models: Loan Approval and Customer Churn

Training and interpreting a decision tree on loan-approval prediction, then encoding, scaling, and bagging/boosting ensembles on telco churn, on my first classification modeling pipeline.

TrainingMLClassification

First Supervised Learning: Classification

Past preprocessing and EDA, I moved on to the model stage. I learned classification with two real datasets.

Decision Tree — Loan Approval Prediction

I predicted approval/rejection (loan_status) with loan.csv.

from sklearn.tree import DecisionTreeClassifier, plot_tree
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder

I went through the following flow.

  • Filled categorical missing values with the mode and numeric with the median, and converted strings to numbers with LabelEncoder
  • Split train and test with train_test_split
  • Drew the tree with plot_tree to see the decision process
  • Evaluated with accuracy, confusion_matrix, classification_report
  • Interpreted which variables drove the decision via feature importance. cibil_score was the main one
  • Compared overfitting: larger max_depth raises train accuracy but hurts generalization

The appeal of trees is that they can explain "why did it predict this?"

Ensembles — Telco Churn Prediction

I went a step further with Telco-Customer-Churn.

  • Converted TotalCharges via pd.to_numeric(errors='coerce') and then handled missing values
  • Mapped Churn Yes/No to 1/0
  • One-hot encoded with get_dummies and drop_first=True, and aligned test columns to train with reindex. This is a basic guard against leakage
  • Scaled only numeric columns with StandardScaler
  • Compared performance of bagging and boosting ensembles in addition to a single tree

Takeaway

Key point

What stuck most was the principle "align test to train." Success hinges less on the model than on preparing data without leakage. I also watched performance rise moving from a single model to an ensemble.