-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloan_data_set.py
762 lines (459 loc) · 18.5 KB
/
loan_data_set.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.preprocessing import RobustScaler
from sklearn.metrics import roc_curve, auc
from sklearn.metrics import roc_auc_score
from sklearn.cluster import KMeans
from sklearn import datasets
from io import StringIO
from sklearn.tree import export_graphviz
from sklearn.model_selection import train_test_split, cross_val_score
from sklearn import tree
from sklearn import metrics
from sklearn.metrics import precision_score, recall_score, f1_score, roc_auc_score, accuracy_score, classification_report,confusion_matrix
get_ipython().run_line_magic('matplotlib', 'inline')
# In[2]:
#load data file
data = pd.read_csv(r"C:\Users\Lt col Haider\OneDrive\IBA\semester 4\Foundations to Data Science\project\loan_data_set.csv")
data.head()
# In[3]:
data.shape
# # Data Cleaning
# In[4]:
#Loan_ID is a unique variable so drop it
data = data.drop(columns = ['Loan_ID'])
# In[5]:
#re-label categorical variables
data.Loan_Status.replace({'Y': 0, 'N':1}, inplace=True)
data.Gender.replace({'Male':1, 'Female':0}, inplace=True)
data.Married.replace({'Yes': 1, 'No':0}, inplace=True)
data.Education.replace({'Graduate': 1, 'Not Graduate':0}, inplace=True)
data.Self_Employed.replace({'Yes': 1, 'No':0}, inplace=True)
# In[6]:
#create dummy variables for 'Property_Area' and 'Dependents'
data = data.join(pd.get_dummies(data.Dependents, prefix='Dependents'))
data.drop(columns= ['Dependents'], inplace=True)
data = data.join(pd.get_dummies(data.Property_Area, prefix='Property_Area'))
data.drop(columns= ['Property_Area'], inplace=True)
# In[7]:
data.head()
# In[8]:
#check for missing values
total = data.isnull().sum().sort_values(ascending = False)
percent = (data.isnull().sum()/data.isnull().count()*100).sort_values(ascending = False)
pd.concat([total, percent], axis=1, keys=['Total', 'Percent']).transpose()
# In[9]:
#Normalize data for effective KNN Imputation
#will manually normalize as NaN values present so preprocessing can't be used
def normalize(data):
return (data - data.min()) * 1.0 / (data.max() - data.min())
data = data.apply(normalize)
# In[10]:
#Apply KNN Imputation
from sklearn.impute import KNNImputer
imputer = KNNImputer(n_neighbors=15)
df = imputer.fit_transform(data)
# In[11]:
#convert array back to dataframe
data = pd.DataFrame(df)
#bring data back in original form
data.columns = ['Gender','Married','Education','Self_Employed','ApplicantIncome','CoapplicantIncome','LoanAmount',
'Loan_Amount_Term','Credit_History','Loan_Status','Dependents_0','Dependents_1','Dependents_2','Dependents_3+',
'Property_Area_Rural','Property_Area_Semiurban','Property_Area_Urban']
data.head()
# In[12]:
#check for missing values again
total = data.isnull().sum().sort_values(ascending = False)
percent = (data.isnull().sum()/data.isnull().count()*100).sort_values(ascending = False)
pd.concat([total, percent], axis=1, keys=['Total', 'Percent']).transpose()
# In[13]:
#check outliers in dataset using Z-Score
from scipy import stats
z = np.abs(stats.zscore(data))
print(z)
threshold = 3
print(np.where(z > 3))
# In[14]:
#remove outliers
data = data[(z < 3).all(axis=1)]
data.shape
# # Exploratory Data Analysis
# In[15]:
data.describe()
# In[16]:
temp = data["Loan_Status"].value_counts()
df = pd.DataFrame({'Loan_Status': temp.index,'values': temp.values})
plt.figure(figsize = (6,6))
plt.title('Default Clients - target value - data unbalance\n (Not Default = 0, Default = 1)')
sns.set_color_codes("pastel")
sns.barplot(x = 'Loan_Status', y="values", data=df)
locs, labels = plt.xticks()
plt.show()
# Data is imbalanced.
# In[17]:
numerical = ['ApplicantIncome','CoapplicantIncome','LoanAmount','Loan_Amount_Term']
categorical = ['Credit_History','Gender','Married','Education','Self_Employed','Dependents_0','Dependents_1','Dependents_2',
'Dependents_3+','Property_Area_Rural','Property_Area_Semiurban','Property_Area_Urban']
# In[18]:
#T Test for numerical columns
p=[]
from scipy.stats import ttest_ind
for i in numerical:
df1=data.groupby('Loan_Status').get_group(0)
df2=data.groupby('Loan_Status').get_group(1)
t,pvalue=ttest_ind(df1[i],df2[i])
p.append(1-pvalue)
plt.figure(figsize=(7,7))
sns.barplot(x=p, y=numerical)
plt.title('Best Numerical Features')
plt.axvline(x=(1-0.05),color='r')
plt.xlabel('1-p value')
plt.show()
# 'CoappliantIncome' has the greatest importance. None of them show statistical significance though.
# In[19]:
#Chi Square test for Categorical Columns
from scipy.stats import chi2_contingency
l=[]
for i in categorical:
pvalue = chi2_contingency(pd.crosstab(data['Loan_Status'],data[i]))[1]
l.append(1-pvalue)
plt.figure(figsize=(7,7))
sns.barplot(x=l, y=categorical)
plt.title('Best Categorical Features')
plt.axvline(x=(1-0.05),color='r')
plt.show()
# 'Credit_History', 'Property_Area_Rural' and 'Property_Area_Semiurban' show statistical significance. 'Dependents_3+' has very low significance, so drop it.
# In[20]:
data = data.drop(columns = ['Dependents_3+'])
# In[21]:
#drop target variable: 'Default'
features = data.drop(columns = ['Loan_Status'])
# In[22]:
#correlation analysis
corr_matrix = features.corr().abs()
corr_matrix
# In[23]:
#Feature Selection
#Select upper triangle of correlation matrix
upper = corr_matrix.where(np.triu(np.ones(corr_matrix.shape), k=1).astype(np.bool))
to_drop = [column for column in upper.columns if any(upper[column] > 0.95)]
#Drop highly correlated attributes
data = data.drop(data[to_drop], axis=1)
data.shape
# No highly correlated attributes found.
# In[24]:
pd.crosstab(data.Married, data.Loan_Status)
# Those not married have a higher percentage on defaulting.
# In[25]:
pd.crosstab(data.Education, data.Loan_Status)
# Graduates are more in number and thus are more in number for both default and not defaut. Not Graduates have a higher percentage of defaulting which makes sense.
# In[26]:
pd.crosstab(data.Dependents_0, data.Loan_Status)
# Percentage of default for those with no dependents and those with dependents is almost the same.
# In[27]:
class_0 = data.loc[data['Loan_Status'] == 0]["ApplicantIncome"]
class_1 = data.loc[data['Loan_Status'] == 1]["ApplicantIncome"]
plt.figure(figsize = (14,6))
plt.title('Default amount (Density Plot)')
sns.set_color_codes("pastel")
sns.distplot(class_1,kde=True,bins=200, color="red")
sns.distplot(class_0,kde=True,bins=200, color="green")
plt.show()
# Data is right skewed. Those with less Applicant Incomes have higher defaulting tendency. The highest default is for value 0.04.
# In[28]:
class_0 = data.loc[data['Loan_Status'] == 0]["LoanAmount"]
class_1 = data.loc[data['Loan_Status'] == 1]["LoanAmount"]
plt.figure(figsize = (14,6))
plt.title('Default amount (Density Plot)')
sns.set_color_codes("pastel")
sns.distplot(class_1,kde=True,bins=200, color="red")
sns.distplot(class_0,kde=True,bins=200, color="green")
plt.show()
# Data has a normal distribution.
# # Pre-Processing
# In[29]:
#Split test and train data
x = data.drop(columns = 'Loan_Status')
y = data['Loan_Status']
#will train on 70% of the data, test on the remaining 30%
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.30, random_state=50)
# In[30]:
y.value_counts(normalize=True)
# Majority class (not default) has 69% samples. Minority class (default) has 31% samples. Data is imbalanced. Thus, will apply SMOTE.
# In[31]:
from imblearn.over_sampling import SMOTE
#so as not to lose any important information, apply SMOTE (Synthetic Minority Oversampling Technique) to fix class imbalance
sm = SMOTE(random_state=10)
x_smote, y_smote = sm.fit_sample(x_train, y_train)
# # Modeling
# # 1. Logistic Regression
# In[32]:
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import GridSearchCV
param_grid = {'C': [0.001, 0.01, 1, 10]}
lr = LogisticRegression(penalty='l2', class_weight='balanced')
lr = GridSearchCV(estimator = lr, param_grid = param_grid, n_jobs = -1)
lr.fit(x_train, y_train)
y_pred = lr.predict(x_test)
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# In[33]:
from sklearn.metrics import roc_curve, auc
y_prob = lr.predict_proba(x_test)[:,1]
false_positive_rate, true_positive_rate, thresholds = roc_curve(y_test, y_prob)
roc_auc = auc(false_positive_rate, true_positive_rate)
import matplotlib.pyplot as plt
plt.figure(figsize=(6,6))
plt.title('Receiver Operating Characteristic')
plt.plot(false_positive_rate,true_positive_rate, color='red',label = 'AUC = %0.2f' % roc_auc)
plt.legend(loc = 'lower right')
plt.plot([0, 1], [0, 1],linestyle='--')
plt.axis('tight')
plt.ylabel('True Positive Rate')
plt.xlabel('False Positive Rate')
# In[34]:
lr.fit(x_smote, y_smote)
y_pred = lr.predict(x_test)
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# Best result on original data = 0.82, AUC = 0.88
# # 2. Decision Tree
# In[35]:
from sklearn.tree import DecisionTreeClassifier
# Decision tree with depth = 2
dt2 = tree.DecisionTreeClassifier(random_state=42, max_depth=2)
dt2.fit(x_train, y_train)
dt2_score_train = dt2.score(x_train, y_train)
print("Training score: ",dt2_score_train)
dt2_score_test = dt2.score(x_test, y_test)
print("Testing score: ",dt2_score_test)
# In[36]:
# Decision tree with depth = 3
dt3 = tree.DecisionTreeClassifier(random_state=42, max_depth=3)
dt3.fit(x_train, y_train)
dt3_score_train = dt3.score(x_train, y_train)
print("Training score: ",dt3_score_train)
dt3_score_test = dt3.score(x_test, y_test)
print("Testing score: ",dt3_score_test)
# In[37]:
# Decision tree with depth = 4
dt4 = tree.DecisionTreeClassifier(random_state=42, max_depth=4)
dt4.fit(x_train, y_train)
dt4_score_train = dt4.score(x_train, y_train)
print("Training score: ",dt4_score_train)
dt4_score_test = dt4.score(x_test, y_test)
print("Testing score: ",dt4_score_test)
# In[38]:
# Decision tree: To the full depth
dt1 = tree.DecisionTreeClassifier()
dt1.fit(x_train, y_train)
dt1_score_train = dt1.score(x_train, y_train)
print("Training score: ", dt1_score_train)
dt1_score_test = dt1.score(x_test, y_test)
print("Testing score: ", dt1_score_test)
# In[39]:
#Compare Training and Testing scores for various tree depths used
print('{:10} {:20} {:20}'.format('depth', 'Training score','Testing score'))
print('{:10} {:20} {:20}'.format('-----', '--------------','-------------'))
print('{:1} {:>25} {:>20}'.format(2, dt2_score_train, dt2_score_test))
print('{:1} {:>25} {:>20}'.format(3, dt3_score_train, dt3_score_test))
print('{:1} {:>25} {:>20}'.format(4, dt4_score_train, dt4_score_test))
print('{:1} {:>23} {:>20}'.format("max", dt1_score_train, dt1_score_test))
# Highest testing accuracy reached at depth 2. At this depth, training accuracy is good too so will go with this.
# In[40]:
y_pred = dt2.predict(x_test)
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# In[41]:
y_prob = dt2.predict_proba(x_test)[:,1]
false_positive_rate, true_positive_rate, thresholds = roc_curve(y_test, y_prob)
roc_auc = auc(false_positive_rate, true_positive_rate)
plt.figure(figsize=(6,6))
plt.title('Receiver Operating Characteristic')
plt.plot(false_positive_rate,true_positive_rate, color='red',label = 'AUC = %0.2f' % roc_auc)
plt.legend(loc = 'lower right')
plt.plot([0, 1], [0, 1],linestyle='--')
plt.axis('tight')
plt.ylabel('True Positive Rate')
plt.xlabel('False Positive Rate')
# In[42]:
dt2.fit(x_smote, y_smote)
dt2_score_train = dt2.score(x_smote, y_smote)
print("Training score: ",dt2_score_train)
dt2_score_test = dt2.score(x_test, y_test)
print("Testing score: ",dt2_score_test)
y_pred = dt2.predict(x_test)
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# Best result on original data = 0.85, AUC = 0.82
# # 3. Random Forest Classifier
# In[43]:
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import RandomizedSearchCV
rf = RandomForestClassifier(n_estimators=100)
# In[44]:
rf.fit(x_train, y_train)
y_pred = rf.predict(x_test)
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# In[45]:
y_prob = rf.predict_proba(x_test)[:,1]
false_positive_rate, true_positive_rate, thresholds = roc_curve(y_test, y_prob)
roc_auc = auc(false_positive_rate, true_positive_rate)
plt.figure(figsize=(6,6))
plt.title('Receiver Operating Characteristic')
plt.plot(false_positive_rate,true_positive_rate, color='red',label = 'AUC = %0.2f' % roc_auc)
plt.legend(loc = 'lower right')
plt.plot([0, 1], [0, 1],linestyle='--')
plt.axis('tight')
plt.ylabel('True Positive Rate')
plt.xlabel('False Positive Rate')
# In[46]:
rf.fit(x_smote, y_smote)
y_pred = rf.predict(x_test)
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# Best result on original data = 0.86, AUC = 0.86
# # 4. Support Vector Machine (SVM)
# In[47]:
from sklearn import svm
from sklearn import metrics
# In[48]:
#Radial Basis Function Kernel with low gamma 0.01
clf = svm.SVC(kernel='rbf', random_state=0, gamma=.01, C=1)
#Train the model using the training sets
clf.fit(x_train, y_train)
#Predict the response for test dataset
y_pred = clf.predict(x_test)
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
confusion_matrix(y_test, y_pred)
print(classification_report(y_test, y_pred))
# In[49]:
#Radial Basis Fnction Kernel with penalty parameter c = 1000.
#classifier starts to become very intolerant to misclassified data points and thus the decision boundary becomes less biased and has more variance (i.e. more dependent on the individual data points)
clf = svm.SVC(kernel='rbf', random_state=0, gamma=.01, C=1000)
#Train the model using the training sets
clf.fit(x_train, y_train)
#Predict the response for test dataset
y_pred = clf.predict(x_test)
#takes too much training time.
from sklearn import metrics
# model accuracy:
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# In[50]:
false_positive_rate, true_positive_rate, thresholds = roc_curve(y_test, y_pred)
roc_auc = auc(false_positive_rate, true_positive_rate)
plt.figure(figsize=(6,6))
plt.title('Receiver Operating Characteristic')
plt.plot(false_positive_rate,true_positive_rate, color='red',label = 'AUC = %0.2f' % roc_auc)
plt.legend(loc = 'lower right')
plt.plot([0, 1], [0, 1],linestyle='--')
plt.axis('tight')
plt.ylabel('True Positive Rate')
plt.xlabel('False Positive Rate')
# In[51]:
#Radial Basis Fnction Kernel with penalty parameter c = 1000.
#classifier starts to become very intolerant to misclassified data points and thus the decision boundary becomes less biased and has more variance (i.e. more dependent on the individual data points)
clf = svm.SVC(kernel='rbf', random_state=0, gamma=.01, C=1000)
#Train the model using the training sets
clf.fit(x_smote, y_smote)
#Predict the response for test dataset
y_pred = clf.predict(x_test)
#takes too much training time.
from sklearn import metrics
# model accuracy:
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# Best result on original data = 0.86, AUC = 0.78
# # 5. Naive Bayes
# In[52]:
from sklearn.naive_bayes import GaussianNB
naive = GaussianNB()
naive.fit(x_train, y_train)
# Make predictions and evalute
y_pred = naive.predict(x_test)
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# In[53]:
y_prob = naive.predict_proba(x_test)[:,1]
false_positive_rate, true_positive_rate, thresholds = roc_curve(y_test, y_prob)
roc_auc = auc(false_positive_rate, true_positive_rate)
plt.figure(figsize=(6,6))
plt.title('Receiver Operating Characteristic')
plt.plot(false_positive_rate,true_positive_rate, color='red',label = 'AUC = %0.2f' % roc_auc)
plt.legend(loc = 'lower right')
plt.plot([0, 1], [0, 1],linestyle='--')
plt.axis('tight')
plt.ylabel('True Positive Rate')
plt.xlabel('False Positive Rate')
# In[54]:
naive.fit(x_smote, y_smote)
# Make predictions and evalute
y_pred = naive.predict(x_test)
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# Best result on original data = 0.86, AUC = 0.88
# # 6. XGBoost Classifier
# In[55]:
from xgboost import XGBClassifier
model = XGBClassifier(silent=False,
scale_pos_weight=1,
learning_rate=0.01,
colsample_bytree = 0.8,
subsample = 0.8,
objective='binary:logistic',
n_estimators=100,
reg_alpha = 0.3,
max_depth=4,
gamma=5)
# In[56]:
model.fit(x_train, y_train)
# Make predictions and evalute
y_pred = model.predict(x_test)
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# In[57]:
y_prob = model.predict_proba(x_test)[:,1]
false_positive_rate, true_positive_rate, thresholds = roc_curve(y_test, y_prob)
roc_auc = auc(false_positive_rate, true_positive_rate)
plt.figure(figsize=(6,6))
plt.title('Receiver Operating Characteristic')
plt.plot(false_positive_rate,true_positive_rate, color='red',label = 'AUC = %0.2f' % roc_auc)
plt.legend(loc = 'lower right')
plt.plot([0, 1], [0, 1],linestyle='--')
plt.axis('tight')
plt.ylabel('True Positive Rate')
plt.xlabel('False Positive Rate')
# In[58]:
model.fit(x_smote, y_smote)
# Make predictions and evalute
y_pred = model.predict(x_test)
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# In[59]:
y_prob = model.predict_proba(x_test)[:,1]
false_positive_rate, true_positive_rate, thresholds = roc_curve(y_test, y_prob)
roc_auc = auc(false_positive_rate, true_positive_rate)
plt.figure(figsize=(6,6))
plt.title('Receiver Operating Characteristic')
plt.plot(false_positive_rate,true_positive_rate, color='red',label = 'AUC = %0.2f' % roc_auc)
plt.legend(loc = 'lower right')
plt.plot([0, 1], [0, 1],linestyle='--')
plt.axis('tight')
plt.ylabel('True Positive Rate')
plt.xlabel('False Positive Rate')
# Best result on original data = 0.87, AUC = 0.89
# In[ ]:
Best Accuracy = 0.87, XGB | Best AUC = 0.89 XGB | Best Model = XGBoost Classifier