Bird
Raised Fist0
Agentic AIml~10 mins

Self-improving agents in Agentic AI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a self-improving agent class with an update method.

Agentic AI
class SelfImprovingAgent:
    def __init__(self, model):
        self.model = model

    def [1](self, data):
        # Improve the model using new data
        self.model.train(data)
Drag options to blanks, or click blank then click option'
Aevaluate
Bpredict
Cinitialize
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'predict' instead of 'update' because prediction does not improve the model.
Using 'initialize' which is for setup, not improvement.
2fill in blank
medium

Complete the code to make the agent improve itself by retraining on its own predictions.

Agentic AI
def self_improve(agent, data):
    predictions = agent.predict(data)
    agent.[1](predictions)
Drag options to blanks, or click blank then click option'
Ainitialize
Breset
Cupdate
Devaluate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'initialize' which resets the model instead of improving it.
Using 'evaluate' which only measures performance.
3fill in blank
hard

Fix the error in the code to correctly implement a self-improving loop.

Agentic AI
for epoch in range(10):
    predictions = agent.predict(data)
    agent.[1](predictions)
    loss = agent.evaluate(data)
    print(f"Epoch {epoch}: Loss = {loss}")
Drag options to blanks, or click blank then click option'
Aupdate
Bpredict
Ctrain
Devaluate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'predict' which does not change the model.
Using 'evaluate' which only measures performance.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps data points to their improved predictions.

Agentic AI
improved_predictions = {point: agent.[1](point) for point in data if agent.[2](point) > 0.5}
Drag options to blanks, or click blank then click option'
Apredict
Bevaluate
Cconfidence_score
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'update' in the comprehension which changes the model instead of predicting.
Using 'evaluate' which returns overall loss, not per data point score.
5fill in blank
hard

Fill all three blanks to implement a self-improving agent loop that predicts, filters, and updates.

Agentic AI
for data_point in dataset:
    prediction = agent.[1](data_point)
    if prediction [2] 0.7:
        agent.[3]([data_point])
Drag options to blanks, or click blank then click option'
Apredict
B>
Cupdate
Devaluate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'evaluate' instead of 'update' to improve the model.
Using '<' instead of '>' which reverses the condition.