Path: blob/master/lessons/lesson_10-sub-Jacob_Koehler/02-BankMarketing-solutions - done.ipynb
1904 views
Kernel: Python 3
In [1]:
In [2]:
In [26]:
Out[26]:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4119 entries, 0 to 4118
Data columns (total 22 columns):
Unnamed: 0 4119 non-null int64
age 4119 non-null int64
job 4119 non-null object
marital 4119 non-null object
education 4119 non-null object
default 4119 non-null object
housing 4119 non-null object
loan 4119 non-null object
contact 4119 non-null object
month 4119 non-null object
day_of_week 4119 non-null object
duration 4119 non-null int64
campaign 4119 non-null int64
pdays 4119 non-null int64
previous 4119 non-null int64
poutcome 4119 non-null object
emp.var.rate 4119 non-null float64
cons.price.idx 4119 non-null float64
cons.conf.idx 4119 non-null float64
euribor3m 4119 non-null float64
nr.employed 4119 non-null float64
y 4119 non-null int64
dtypes: float64(5), int64(7), object(10)
memory usage: 708.0+ KB
In [27]:
In [28]:
In [29]:
Out[29]:
In [30]:
Out[30]:
admin. 1012
blue-collar 884
technician 691
services 393
management 324
retired 166
self-employed 159
entrepreneur 148
unemployed 111
housemaid 110
student 82
unknown 39
Name: job, dtype: int64
In [31]:
Out[31]:
university.degree 1264
high.school 921
basic.9y 574
professional.course 535
basic.4y 429
basic.6y 228
unknown 167
illiterate 1
Name: education, dtype: int64
In [32]:
Out[32]:
university.degree 3.258703
high.school 4.472313
basic.9y 7.175958
professional.course 7.699065
basic.4y 9.601399
basic.6y 18.065789
unknown 24.664671
illiterate 4119.000000
Name: education, dtype: float64
In [33]:
Out[33]:
thu 860
mon 855
tue 841
wed 795
fri 768
Name: day_of_week, dtype: int64
In [34]:
In [35]:
Out[35]:
In [36]:
In [37]:
In [38]:
In [53]:
In [40]:
Out[40]:
0 3668
1 451
Name: y, dtype: int64
In [41]:
Out[41]:
0.890507404709881
In [54]:
Out[54]:
The DummyClassifier(constant=None, random_state=None, strategy='stratified')
has accuracy
0.8116504854368932
The LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
intercept_scaling=1, max_iter=100, multi_class='ovr', n_jobs=1,
penalty='l2', random_state=None, solver='liblinear', tol=0.0001,
verbose=0, warm_start=False)
has accuracy
0.8815533980582524
The KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',
metric_params=None, n_jobs=1, n_neighbors=4, p=2,
weights='uniform')
has accuracy
0.8786407766990292
In [51]:
In [43]:
Out[43]:
In [44]:
In [45]:
Out[45]:
array([[908, 0],
[122, 0]])
In [46]:
In [47]:
In [48]:
Out[48]:
LogisticRegression(C=1.0, class_weight='balanced', dual=False,
fit_intercept=True, intercept_scaling=1, max_iter=100,
multi_class='ovr', n_jobs=1, penalty='l2', random_state=None,
solver='liblinear', tol=0.0001, verbose=0, warm_start=False)
In [49]:
Out[49]:
0.5640776699029126
In [50]:
Out[50]:
array([[524, 384],
[ 65, 57]])
In [56]:
In [ ]:
In [ ]: