|
73 | 73 |
|
74 | 74 | cap_gain_groups = ['0-10K', '10-20K', '20-30K', '30-40K', '40-50K', '50-60K', '60-70K', '70-80K', '80-90K', '90-100K'] |
75 | 75 | 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'] |
78 | 79 |
|
79 | 80 | for m, feat in enumerate(cap_feat): |
80 | 81 | n_groups_cap = len(gr_set[m]) |
81 | 82 | less_than_50 = [0] * n_groups_cap |
82 | 83 | more_than_50 = [0] * n_groups_cap |
83 | 84 | d_cap = 0 |
84 | | - steps = [10000, 500] |
| 85 | + steps = [10000, 500,10] |
85 | 86 | offset = 0 |
86 | 87 | for agn in range(len(gr_set[m])): |
87 | 88 | if agn == len(gr_set[m]) - 1: offset = 100 |
|
101 | 102 | rects2 = plt.bar(index + bar_width, more_than_50, bar_width, alpha=opacity, color='g', label='>50K') |
102 | 103 | plt.title('Income by {}'.format(feat)) |
103 | 104 | plt.ylabel('No. Records') |
104 | | - plt.ylim((0, 2000)) |
| 105 | + if feat in ['capital-gain', 'capital-loss']: |
| 106 | + plt.ylim((0, 2000)) |
105 | 107 | plt.xticks(index + bar_width / 2.0, gr_set[m], rotation='vertical') |
106 | 108 | plt.legend(frameon=False, loc='upper right', fontsize='small') |
107 | 109 | plot_num += 1 |
108 | 110 |
|
109 | 111 | plt.tight_layout() |
| 112 | +plt.savefig('feat_selection.pdf') |
110 | 113 | plt.show() |
111 | 114 |
|
112 | 115 |
|
113 | | - |
|
0 commit comments