MLCrack

    REINFORCEMENT LEARNING · INTERVIEW QUESTION

    What is the role of a policy in reinforcement learning?

    🟢 beginner · Fundamentals & MDPs

    Hint: A policy maps states to actions — it defines the agent's behavior.

    Answer

    A policy π\pi defines the agent's behavior — it maps states to actions.

    Types

    Deterministic: a=π(s)a = \pi(s) — one action per state.

    Stochastic: π(a∣s)=P(At=a∣St=s)\pi(a|s) = P(A_t = a | S_t = s) — probability distribution over actions.

    Optimal Policy

    The optimal policy π∗\pi^* maximizes expected cumulative reward: π∗=arg⁡max⁡πE[∑t=0∞γtrt∣π]\pi^* = \arg\max_\pi \mathbb{E}\left[\sum_{t=0}^{\infty} \gamma^t r_t \mid \pi\right]

    Learning Policies

    MethodHow
    Value-basedLearn Q∗Q^*, derive policy as π(s)=arg⁡max⁡aQ(s,a)\pi(s) = \arg\max_a Q(s,a)
    Policy gradientDirectly parameterize and optimize πθ\pi_\theta
    Actor-criticLearn both policy (actor) and value function (critic)

    A good policy balances exploration (trying new actions) and exploitation (using known good actions).