|
46 | 46 | # assembling the committee |
47 | 47 | committee = Committee(learner_list=learner_list) |
48 | 48 |
|
49 | | -# visualizing the initial predictions |
| 49 | +# visualizing the Committee's predictions per learner |
| 50 | + |
50 | 51 | with plt.style.context('seaborn-white'): |
51 | 52 | plt.figure(figsize=(n_members*7, 7)) |
52 | 53 | for learner_idx, learner in enumerate(committee): |
|
55 | 56 | plt.title('Learner no. %d initial predictions' % (learner_idx + 1)) |
56 | 57 | plt.show() |
57 | 58 |
|
58 | | -# visualizing the Committee's predictions per learner |
| 59 | +# visualizing the initial predictions |
59 | 60 | with plt.style.context('seaborn-white'): |
60 | 61 | plt.figure(figsize=(7, 7)) |
61 | 62 | prediction = committee.predict(iris['data']) |
62 | 63 | plt.scatter(x=pca[:, 0], y=pca[:, 1], c=prediction, cmap='viridis', s=50) |
63 | 64 | plt.title('Committee initial predictions, accuracy = %1.3f' % committee.score(iris['data'], iris['target'])) |
64 | 65 | plt.show() |
65 | 66 |
|
66 | | -# query by committee |
67 | | -n_queries = 10 |
68 | | -for idx in range(n_queries): |
69 | | - query_idx, query_instance = committee.query(X_pool) |
70 | | - committee.teach( |
71 | | - X=X_pool[query_idx].reshape(1, -1), |
72 | | - y=y_pool[query_idx].reshape(1, ) |
73 | | - ) |
74 | | - # remove queried instance from pool |
75 | | - X_pool = np.delete(X_pool, query_idx, axis=0) |
76 | | - y_pool = np.delete(y_pool, query_idx) |
| 67 | + # query by committee |
| 68 | + n_queries = 10 |
| 69 | + for idx in range(n_queries): |
| 70 | + query_idx, query_instance = committee.query(X_pool) |
| 71 | + committee.teach( |
| 72 | + X=X_pool[query_idx].reshape(1, -1), |
| 73 | + y=y_pool[query_idx].reshape(1, ) |
| 74 | + ) |
| 75 | + # remove queried instance from pool |
| 76 | + X_pool = np.delete(X_pool, query_idx, axis=0) |
| 77 | + y_pool = np.delete(y_pool, query_idx) |
77 | 78 |
|
78 | 79 | # visualizing the final predictions per learner |
79 | 80 | with plt.style.context('seaborn-white'): |
|
0 commit comments