Get startedGet started for free

Comparing slogans for a gym campaign

You're working with an advertising agency to evaluate two models that generate slogans for a gym campaign. Each model has produced a list of slogans with corresponding effectiveness scores. Your task is to compare the slogans generated by each model, determine which model is better overall, and calculate the success rate of each model.

The slogans have been preloaded as slogans_X and slogans_Y, lists of tuples containing the slogan and its score.

This exercise is part of the course

Reinforcement Learning from Human Feedback (RLHF)

View Course

Exercise instructions

  • For each pair of slogans, if the score of slogan X is higher, increment wins_X by 1, while if the score of slogan Y is higher, increment wins_Y by 1.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

def evaluate_slogans(slogans_X, slogans_Y):
    wins_X, wins_Y = 0, 0
    for (slogan_X, score_X), (slogan_Y, score_Y) in zip(slogans_X, slogans_Y):
        # Assign one point to X if score X is higher, otherwise to Y
        ____
    success_rate_X = (wins_X / len(slogans_X)) * 100
    success_rate_Y = (wins_Y / len(slogans_Y)) * 100
    return success_rate_X, success_rate_Y

results = evaluate_slogans(slogans_X, slogans_Y)
print(f"The resulting scores are {results}")
Edit and Run Code