Active learning loop
Now that you've set up your active learner, it's time to use it! In this exercise, you'll implement a loop that will allow to continuously improve the categorization of the data.
The dataset has been loaded with X_labeled
for labeled training data, X_unlabeled
for unlabeled training data, and y_labeled
for labels.
The learner
object has been pre-imported.
This exercise is part of the course
Reinforcement Learning from Human Feedback (RLHF)
Exercise instructions
- Implement a loop that will run
10
queries. - In each iteration, have the learner teach itself using the current labeled data.
- Use the learner to query the most uncertain data points from the unlabeled data, setting the number of instances to
5
. - Update the unlabeled dataset accordingly.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Set the number of queries
____
for _ in range(n_queries):
# Use the current labeled data
____
# Query from unlabeled data
query_idx, _ = ____
X_new, y_new = X_unlabeled[query_idx], y[query_idx]
X_labeled = np.vstack((X_labeled, X_new))
y_labeled = np.append(y_labeled, y_new)
# Update the unlabeled dataset
X_unlabeled = np.delete(____, query_idx, axis=0)