Decision Tree Classifier for Job Application
IMAGE
PROBLEM STATEMENT
The presented use case includes several parameters that are analyzed while selecting the prospective employee such as age, marks of 10th, 12th, graduation & post graduation, hands on tools experience, work experience, current ctc and location preference. These are considered as predictors and whether the person is selected or not is considered as target variable.Â
CODE:
import pandas as pd import numpy as np import matplotlib.pylab as plt from sklearn.model_selection import train_test_split from sklearn.tree import DecisionTreeClassifier from sklearn.metrics import classification_report import sklearn.metrics
data=pd.read_csv('Job_Application.csv')
predictors = data[['Age','SSC','HSC','Grad','PG','Python','SQL','Excel','Work_ex','Current_CTC','Mumbai','Bangalore','Delhi','Notice_period']] targets = data.Selected
pred_train,pred_test,tar_train,tar_test = train_test_split(predictors, targets,test_size=0.4)
pred_train.shape pred_test.shape tar_train.shape tar_test.shape
classifier = DecisionTreeClassifier() classifier=classifier.fit(pred_train,tar_train) predictions=classifier.predict(pred_test)
sklearn.metrics.confusion_matrix(tar_test,predictions) sklearn.metrics.accuracy_score(tar_test,predictions)
from sklearn import tree from sklearn.tree._export import plot_tree import graphviz feature_names=['Age','SSC','HSC','Grad','PG','Python','SQL','Excel','Work_ex','Current_CTC','Mumbai','Bangalore','Delhi','Notice_period'] cn=['Yes','No'] dot_data=tree.export_graphviz(classifier,out_file='tree.dot',feature_names=feature_names,class_names=cn,filled=True) graph=graphviz.Source(dot_data)
After this, we need to run a command in the command prompt to convert the dot file into an image.
dot -Tpng tree.dot -o tree.png
SUMMARY
The current model indicates that the location Mumbai is relatively an accurate measure to classify the candidates who will be selected or not. I compared two models - one with the 60-40 train test split and other with 70-30 train test split. 60-40 data split gave an accuracy of 75% whereas 70-30 gave an accuracy of 55%. This shows that running the model on large data sets improves the accuracy. Further more, due to limited amount of records in the dataset, we had reached the gini impurity of 0 at the terminal nodes and also many variables could not make it to the tree. We can further improve the accuracy and the reliability of the model by running it on larger datasets and introducing algorithm tuning methods.











