Path: blob/master/ML Classification using Python/Hiring_DecisionTree_CaseStudy.ipynb
4745 views
Kernel: Python 3 (ipykernel)
Hiring Decision Tree Case Study with GridSearchCV
In [1]:
Out[1]:
Handle Missing Values (if any)
In [2]:
Out[2]:
YearsExperience 0
EducationLevel 0
SkillsScore 0
CertificationCount 0
Hired 0
dtype: int64
Encode Categorical Column
In [3]:
Out[3]:
Exploratory Data Analysis
In [4]:
Out[4]:
In [5]:
Out[5]:
Train-Test Split
In [6]:
GridSearchCV for Best Decision Tree
In [7]:
Out[7]:
({'criterion': 'gini', 'max_depth': 3, 'min_samples_split': 2},
0.9458333333333332)
Train Final Model
In [8]:
Out[8]:
Accuracy: 0.9291666666666667
precision recall f1-score support
0 0.93 0.96 0.94 145
1 0.93 0.88 0.91 95
accuracy 0.93 240
macro avg 0.93 0.92 0.93 240
weighted avg 0.93 0.93 0.93 240
Confusion Matrix
In [9]:
Out[9]:
Feature Importance
In [10]:
Out[10]:
Decision Tree Visualization
In [11]:
Out[11]:
In [12]:
Out[12]:
Model saved as hiring_decision_tree_model.pkl
Add a Prediction Function (User Input → Model Output)
This function takes candidate details and returns Hired / Not Hired.
In [13]:
Out[13]:
{'Prediction': 'Hired',
'Probability_Not_Hired': 0.085,
'Probability_Hired': 0.915}
In [14]:
Out[14]:
{'Prediction': 'Hired',
'Probability_Not_Hired': 0.031,
'Probability_Hired': 0.969}