# Are model-free and off-policy algorithms the same?

In respect of RL, is model-free and off-policy the same thing, just different terminology? If not, what are the differences? I've read that the policy can be thought of as 'the brain', or decision making part, of machine learning application, where it stores its learnings and refers to it when a new action is required in the new state.

In respect of RL, is model-free and off-policy the same thing, just different terminology?

No, they are entirely different terms, with the only thing they have in common is that they are both ways in which an RL agent can vary. An agent is generally either working off-policy or on-policy, and is generally either model-based or model-free. These things can otherwise appear in all four combinations.

If not, what are the differences?

### Model-based vs model-free

A model-based learning agent uses knowledge of the environment dynamics in order to make predictions of expected outcomes. A model-free learning agent does not use such knowledge. The model here might be provided explicitly by the developer - that could be code for physics to predict a mechanical system, or it might be the rules of a board game that the agent is allowed to know and query to predict outcomes of actions before taking them. Models can also be learned statistically from experience, although that is harder to make effective.

### On-policy vs off-policy

An on-policy agent learns statistically about how it is currently acting, and assuming a control problem, then uses that knowledge to change how it should act in future. An off-policy agent can learn statistically from other observed behaviours (including its own past behaviour, or random and exploratory behaviour) and use that knowledge to understand how a different target behaviour would perform.

Off-policy learning is a strict generalisation of on-policy learning and includes on-policy as a special case. However, off-policy learning is also often harder to perform since observations typically contain less relevant data.

I've read that the policy can be thought of as 'the brain', or decision making part, of machine learning application, where it stores its learnings and refers to it when a new action is required in the new state.

That's basically correct when considering how an agent learns how to behave in an environment.

You are assigning a bit too much to the word policy here. A policy is strictly only the mapping from a state to an action (or probability distribution over actions), and often written $$\pi(a|s)$$, i.e. the probability of taking action $$a$$ given the agent is in state $$s$$. The "brain" part might include how the agent learns that policy. That could include storing past experience or some summary of past experience in e.g. a neural network.

However, outside of machine learning context, a really simple function containing and if/then statement would also be a policy, if the input to the function was a state of the environment, and the output was an action or probabilities of taking a range of actions. Behaving completely randomly is also a policy, but outside of very specific environments (e.g. Rock/Paper/Scissors) it is usually not the optimal thing to do.

• Many thanks for your thorough response. I have a couple of follow-up questions: In a board game environment, how does a model-free learning agent know what the rule of game are - how does it know it can or cannot perform X action? On Wikipedia, it shows Q-Learning as off-policy, though you have said "a policy is strictly only the mapping from a state to an action". Q-Learning, however, is that, no? You're creating a matrix (a mapping) of which actions to take in which state. Am I missing something crucial? Thanks Feb 1 '20 at 23:04
• @mason7663: If you want details, you will need to ask a separate question. In short, the available actions are a property of the environment and the agent can be informed of them (perhaps on each turn) without knowing the full model. Q-learning is an off-policy method, and it does more than simply contain a way of generating policies. The other things it does, such as the update rule, are important and they are not "the policy" Feb 2 '20 at 8:07