Skip to content

Commit 128eaa7

Browse files
committed
add: query by committee jupyter notebook
1 parent fd14184 commit 128eaa7

5 files changed

Lines changed: 379 additions & 214 deletions

File tree

docs/source/content/examples/Bootstrapping-and-bagging.rst

Lines changed: 0 additions & 92 deletions
This file was deleted.

docs/source/content/examples/Query-by-committee.rst

Lines changed: 0 additions & 102 deletions
This file was deleted.

docs/source/content/examples/query_by_committee.ipynb

Lines changed: 365 additions & 0 deletions
Large diffs are not rendered by default.

docs/source/content/examples/stream-based_sampling.ipynb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,6 @@
263263
"\n",
264264
"plt.show()"
265265
]
266-
},
267-
{
268-
"cell_type": "code",
269-
"execution_count": null,
270-
"metadata": {},
271-
"outputs": [],
272-
"source": []
273266
}
274267
],
275268
"metadata": {

examples/query_by_committee.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
# assembling the committee
4747
committee = Committee(learner_list=learner_list)
4848

49-
# visualizing the initial predictions
49+
# visualizing the Committee's predictions per learner
50+
5051
with plt.style.context('seaborn-white'):
5152
plt.figure(figsize=(n_members*7, 7))
5253
for learner_idx, learner in enumerate(committee):
@@ -55,25 +56,25 @@
5556
plt.title('Learner no. %d initial predictions' % (learner_idx + 1))
5657
plt.show()
5758

58-
# visualizing the Committee's predictions per learner
59+
# visualizing the initial predictions
5960
with plt.style.context('seaborn-white'):
6061
plt.figure(figsize=(7, 7))
6162
prediction = committee.predict(iris['data'])
6263
plt.scatter(x=pca[:, 0], y=pca[:, 1], c=prediction, cmap='viridis', s=50)
6364
plt.title('Committee initial predictions, accuracy = %1.3f' % committee.score(iris['data'], iris['target']))
6465
plt.show()
6566

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)
7778

7879
# visualizing the final predictions per learner
7980
with plt.style.context('seaborn-white'):

0 commit comments

Comments
 (0)