function [w, loss_history] = train(X, y, mu, num_iters, reg_type, lambda)
% Funkcija koja vrsi trening modela. 

w = zeros(size(X, 2), 1);
loss_history = zeros(num_iters, 1);

for i = 1:num_iters
    [loss, grad] = loss_function(X, y, w, reg_type, lambda);
    w = w - mu .* grad;
    loss_history(i) = loss;
end

end
