Skip to content

Commit 915163b

Browse files
committed
added hours-per-week plot
1 parent 2719525 commit 915163b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

features_plot.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,16 @@
7373

7474
cap_gain_groups = ['0-10K', '10-20K', '20-30K', '30-40K', '40-50K', '50-60K', '60-70K', '70-80K', '80-90K', '90-100K']
7575
cap_loss_groups = ['0-500', '500-1K', '1-1.5K', '1.5-2K', '2-2.5K', '2.5-3K', '3-3.5K', '3.5-4K','4-4.5K', '4.5-5K']
76-
gr_set = [cap_gain_groups, cap_loss_groups]
77-
cap_feat = ['capital-gain', 'capital-loss']
76+
weekly_hours = ['0-10h', '10-20h', '20-30h', '30-40h', '40-50h', '50-60h', '60-70h', '70-80h','80-90h', '90-99h']
77+
gr_set = [cap_gain_groups, cap_loss_groups, weekly_hours]
78+
cap_feat = ['capital-gain', 'capital-loss', 'hours-per-week']
7879

7980
for m, feat in enumerate(cap_feat):
8081
n_groups_cap = len(gr_set[m])
8182
less_than_50 = [0] * n_groups_cap
8283
more_than_50 = [0] * n_groups_cap
8384
d_cap = 0
84-
steps = [10000, 500]
85+
steps = [10000, 500,10]
8586
offset = 0
8687
for agn in range(len(gr_set[m])):
8788
if agn == len(gr_set[m]) - 1: offset = 100
@@ -101,13 +102,14 @@
101102
rects2 = plt.bar(index + bar_width, more_than_50, bar_width, alpha=opacity, color='g', label='>50K')
102103
plt.title('Income by {}'.format(feat))
103104
plt.ylabel('No. Records')
104-
plt.ylim((0, 2000))
105+
if feat in ['capital-gain', 'capital-loss']:
106+
plt.ylim((0, 2000))
105107
plt.xticks(index + bar_width / 2.0, gr_set[m], rotation='vertical')
106108
plt.legend(frameon=False, loc='upper right', fontsize='small')
107109
plot_num += 1
108110

109111
plt.tight_layout()
112+
plt.savefig('feat_selection.pdf')
110113
plt.show()
111114

112115

113-

0 commit comments

Comments
 (0)