Statistical Models, Loss Functions and Training as Optimization
Statistical Models
A statistical model is simply a mathematical function. Different models are functions of different forms, but all require the specification of a number of parameters that are found in the function. We will normally use to represent the ith parameter of a model. We can think of the general form of statistical models arising from supervised learning as being one of:
Where different model types utilize different functions for .
Note that although the discussion in this article works with supervised learning cases, the process discussed is true of all types of learning.
The distinction between a model that outputs a ‘point estimates’ of Y, giving the estimated value(s) of the target variable(s), and one that outputs a probability distribution over the values of the target variable(s) is not really required: We can think of the former as a special case of the latter, where all probability is located at a specific value. Nonetheless it is often important, so we emphasise it here.
As concrete examples, we examine two models that you should already be familiar with: linear regression and logistic regression. With a single input feature and a single target variable (the target variable in the logistic regression case is binary), they take the forms:
Linear Regression:
Logistic Regression: 
We remind you that logistic regression can also be understood as linear classifier (rather than a regression model of the probability) with the form:
Logistic Regression:
Where if is true and 0 otherwise. For the remainder of this step we assume the first form (which is in any case used in the optimization process to find the parameters of the second form).
We see that the two types of statistical models have different forms, and also that each formula will produce infinitely many different models depending on the values assigned to the parameters.
Deciding upon the values to assign to the parameters of a model based on available data is the process of learning a model from, or fitting a model to, data.
Training Models
Selecting values for model parameters given data is an optimization problem. This process requires the specification of a loss function, . Examples include MSE or negative Log Likelihood:
In the simplest case, we seek to find values for the parameters that minimize the Loss function on the training data.
In the cases we will look at in this course, such optimization problems will be either solvable analytically or numerically. We give examples of both cases here.
For instance, optimal parameter values for a linear regression model given a MSE loss function and given data (X and Y matrices) can be solved analytically, in the familiar derivation:
To find the optimal values, we set the derivative to 0:
Therefore:
You should memorize the final formula, since we will see variants on it in a number of places later.
Optimal (or near optimal) solutions to the optimization problem for logistic regression, on the other hand, requires a numerical solution. We briefly review a basic gradient descent algorithm that could be used to solve the logistic regression optimzation problem:
Basic Gradient Descent Algorithm
A constant learning rate, R, or a learning rate schedule, R(i), where i is the step of the algorithm is specified. We assume a constant rate for simplicity.

Initial random parameter values are assigned.

Repeat until convergence:
i. Calculate the partial derivatives of the parameters with respect to the Loss function.
ii. Update the parameter values given their partial derivatives and the learning rate:
In fact, logistic regression would normally use second order information (estimating the Hessian). But we will see this basic gradient descent algorithm again soon, in circumstances where it would be infeasible to calculate or even estimate second order information. So try and get comfortable with it.
© Dr Michael Ashcroft