DEV Community

Saurab Gyawali
Saurab Gyawali

Posted on

How Does a Machine Actually Learn From Data ?

Machine learning algorithm is the process consists in iteratively assessing a parameterized model over data with an objective function , calculating the gradient of this function in essense with the model parameters then updating the latter in order to minimize this objective function.

Data → Prediction → Loss → Gradient → Parameter update → Repeat​

Learning means improving performance on a task by using data, not by being explicitly programmed for every case .

  1. Data
    Data is a collection of observed examples used to estimate the parameters of a model. In supervised learning, the training data is typically written as D = { xi , yi } for range ( 0 , n ) where:
    xi​ = input / eatures
    yi​ = target output
    i = index of the observation
    A dataset therefore provides the information against which the model's predictions are evaluated.

  2. Prediction
    Prediction is the output produced by a model when its current parameters are applied to an input.
    A model can be represented as:
    ŷ =f( x ; θ )
    where:
    x = input
    θ = model parameters
    f = model function
    ŷ​ = predicted output
    The prediction depends on the current values of the parameters. The prediction tells us what the model currently produces.

  3. Loss
    Loss is a numerical measure of the discrepancy between the model's prediction and the target value.
    It is represented as: L ( ŷ , y )
    A loss function defines what the model is trying to minimize. The loss tells us how undesirable that prediction is according to the chosen objective.

  4. Gradient
    The gradient The gradient is the vector of partial derivatives of the objective function with respect to the parameters of the model. The gradient indicates the way how the objective is affected as each parameter is modified, and thus provides the direction in which the objective function increase most rapidly. Most optimizers update the parameters by moving in the opposite direction to the gradient in order to minimize the objective.

  5. Parameter Update
    A parameter update changes the model's parameters using information from the gradient so that the objective function is expected to decrease.

  6. Repeat
    After updating the parameters, the model uses the new parameters to produce new predictions.
    The process is therefore repeated:
    Data → Prediction → Loss → Gradient → Parameter Update → Repeat​
    Each iteration is an optimization step.
    As training progresses, the parameters are adjusted toward values that produce a lower objective value, assuming the optimization procedure is working effectively.

Some other learning paradigms :
Unsupervised: The loss is defined without labels (reconstruction error, contrastive loss, etc.). The model still adjusts θ or theta θ to reduce that loss .

Reinforcement learning: The “loss” is replaced by a reward signal; the agent adjusts a policy (again usually parameterized by θ \theta θ) to increase expected cumulative reward, typically via policy gradients or value-function approximation .

Self-supervised / representation learning: The model invents its own predictive tasks from the raw data and optimizes those surrogate losses .

So what machine learning , deep learning and related fields actually ‘learn from data’ fundamentally is just : calculate current error on parameters , repeatedly , force parameters in the direction of reducing the error . Machine learning is the process of finding parameter values that make a model perform well on a specified objective, using data and optimizations .

Top comments (0)