gbnet.gblinear ============== .. py:module:: gbnet.gblinear Classes ------- .. autoapisummary:: gbnet.gblinear.GBLinear Functions --------- .. autoapisummary:: gbnet.gblinear.ridge_regression Module Contents --------------- .. py:class:: GBLinear(input_dim, output_dim, bias = True, lr = 0.5, min_hess = 0.0, lambd = 0.01) Bases: :py:obj:`gbnet.base.BaseGBModule` A linear gradient boosting module that uses gradient boosting for updates. This module implements a linear layer that can be trained using gradient boosting. It maintains state between iterations and updates parameters using computed gradients and hessians. :param input_dim: Input feature dimension :type input_dim: int :param output_dim: Output prediction dimension :type output_dim: int :param bias: Whether to include a bias term. Defaults to True. :type bias: bool, optional :param lr: Learning rate for parameter updates. Defaults to 0.5. :type lr: float, optional :param min_hess: Minimum hessian threshold. Defaults to 0.0. :type min_hess: float, optional :param lambd: L2 regularization parameter. Defaults to 0.01. :type lambd: float, optional :ivar linear: The underlying linear layer :vartype linear: nn.Linear :ivar FX: Current predictions tensor :vartype FX: torch.Tensor :ivar input: Input data cache :vartype input: numpy.ndarray :ivar g: Gradient cache :vartype g: torch.Tensor :ivar h: Hessian cache :vartype h: torch.Tensor .. py:attribute:: input_dim .. py:attribute:: output_dim .. py:attribute:: min_hess :value: 0.0 .. py:attribute:: bias :value: True .. py:attribute:: lr :value: 0.5 .. py:attribute:: lambd :value: 0.01 .. py:attribute:: linear .. py:attribute:: FX :value: None .. py:attribute:: input :value: None .. py:attribute:: g :value: None .. py:attribute:: h :value: None .. py:method:: _input_checking_setting(x) .. py:method:: forward(x) .. py:method:: gb_calc() Calculate gradients and stores in the object .. py:method:: gb_step() Uses stored gradients to update weights .. py:function:: ridge_regression(X, y, lambd) Solves ridge regression using Cholesky decomposition. Fastest method tested. :param X: Design matrix of shape (n_samples, n_features) :type X: np.ndarray :param y: Target values of shape (n_samples,) :type y: np.ndarray :param lambd: Ridge regularization parameter :type lambd: float :returns: Fitted coefficients of shape (n_features,) :rtype: np.ndarray The function solves the ridge regression problem: min_beta ||X beta - y||^2 + lambd ||beta||^2 using the normal equations and Cholesky decomposition for numerical stability.