# Can supervised learning be recast as reinforcement learning problem?

Let's assume that there is a sequence of pairs $$(x_i, y_i), (x_{i+1}, y_{i+1}), \dots$$ of observations and corresponding labels. Let's also assume that the $$x$$ is considered as independent variable and $$y$$ is considered as the variable that depends on $$x$$. So, in supervised learning, one wants to learn the function $$y=f(x)$$.

Can reinforcement learning be used to learn $$f$$ (possibly, even learning the symbolic form of $$f(x)$$)?

Just some sketches how can it be done: $$x_i$$ can be considered as the environment and each $$x_i$$ defines some set of possible "actions" - possible symbolic form of $$f(x)$$ or possible numerical values of parameters for $$f(x)$$ (if the symbolic form is fized). And concrete selected action/functional form $$f(x, a)$$ (a - set of parameters) can be assigned reward from the loss function: how close the observation $$(x_i, y_i)$$ is to the value that can be inferred from $$f(x)$$.

Are there ideas or works of RL along the framework that I provided in the previous passage?

Suppose you have the training dataset $$\mathcal{D} = \{ (x_i, y_i \}_{i=1}^N$$, where $$x_i$$ is an observation and $$y_i$$ the corresponding label. Then let $$x_i$$ be a state and let $$f(x_i) = \hat{y}_i$$, where $$f$$ is your (current) model, be an action. So, the predicted label of observation $$x_i$$ corresponds to the action taken in state $$x_i$$. The reward received after having taken action $$f(x_i)$$ in state $$x_i$$ can then be defined as the loss $$|f(x_i) - y_i|$$ (or any other suitable loss).
The minimization of this loss is then equivalent to the maximization of the (expected) reward. Therefore, in theory, you could use trajectories of the form $$T=\{(x_1, f(x_1), |f(x_1) - y_1|), \dots, (x_N, f(x_N), |f(x_N) - y_N|)\}$$ to learn a value function $$q$$ (for example, with Q-learning) or a policy $$\pi$$, which then, given a new state $$x_{\text{new}}$$ (an observation) produces an action $$f(x_{\text{new}})$$ (the predicted label).