The talk will describe a variational framework for empirical risk minimization. In its most general form the framework concerns a two-sep estimation procedure in which (i) the trajectory of an observed (but unknown) dynamical system is fit to a trajectory from a known reference dynamical system by minimizing average per-state loss, and (ii) a parameter estimate is obtained from the initial state of the best fit reference trajectory. We show that the empirical risk of the best fit trajectory converges almost surely to a constant that can be expressed in variational form as the minimal expected loss over dynamically invariant couplings (joinings) of the observed and reference systems. Moreover, the family of joinings minimizing the expected loss fully characterizes the asymptotic behavior of the estimated parameters. We will illustrate the variational framework with applications to the well-studied problems of maximum likelihood estimation and non-linear regression, and then consider the analysis of system identification from quantized trajectories subject to noise, a problem in which the models themselves exhibit dynamical behavior across time.