gbnet.models.ordinal_regression =============================== .. py:module:: gbnet.models.ordinal_regression Classes ------- .. autoapisummary:: gbnet.models.ordinal_regression.GBOrd gbnet.models.ordinal_regression.OrdinalLogisticLoss Functions --------- .. autoapisummary:: gbnet.models.ordinal_regression.loadModule Module Contents --------------- .. py:function:: loadModule(module) .. py:class:: GBOrd(num_classes, nrounds=None, params=None, module_type='LGBModule', min_hess=0.0) Bases: :py:obj:`sklearn.base.BaseEstimator`, :py:obj:`sklearn.base.ClassifierMixin` Gradient Boosting Ordinal Regression model. This model combines gradient boosting with ordinal regression to predict ordered categorical outcomes. It uses either XGBoost or LightGBM as the underlying boosting engine wrapped in a PyTorch module. :param num_classes: Number of ordinal classes to predict :type num_classes: int :param nrounds: Number of boosting rounds. Defaults to 500 for XGBModule and 1000 for LGBModule. :type nrounds: int, optional :param params: Additional parameters passed to the gradient boosting model. :type params: dict, optional :param module_type: Type of gradient boosting module to use, either "XGBModule" or "LGBModule". Defaults to "LGBModule". :type module_type: str, optional :param min_hess: Minimum hessian value for numerical stability. Defaults to 0.0. :type min_hess: float, optional :ivar model_: Trained gradient boosting module. Set after fitting. :vartype model_: XGBModule or LGBModule :ivar losses_: List of loss values recorded at each training iteration. :vartype losses_: list :ivar min_targets: Minimum value in training targets, used for label normalization. :vartype min_targets: int .. method:: fit(X, y) Trains the model using input features X and ordinal targets y. .. method:: predict(X) Predicts ordinal class labels for input features X. .. rubric:: Notes The model uses an ordinal logistic loss function to handle ordered categorical outcomes. The gradient boosting model learns a single score which is transformed into class probabilities via learned thresholds. .. py:attribute:: nrounds :value: None .. py:attribute:: params :value: None .. py:attribute:: model_ :value: None .. py:attribute:: losses_ :value: [] .. py:attribute:: module_type :value: 'LGBModule' .. py:attribute:: Module .. py:attribute:: loss_fn .. py:attribute:: num_classes .. py:attribute:: min_hess :value: 0.0 .. py:method:: fit(X, y=None) .. py:method:: score(X, y) Return the negative log likelihood score for input X and targets y. :param X: Input features. :type X: array-like of shape (n_samples, n_features) :param y: Target values. :type y: array-like of shape (n_samples,) :returns: Negative log likelihood score. Lower values indicate better fit. :rtype: float .. py:method:: predict_proba(X) Predict class probabilities for input X. :param X: Input features. :type X: array-like of shape (n_samples, n_features) :returns: Predicted class probabilities. :rtype: array-like of shape (n_samples, n_classes) .. py:method:: predict(X, return_logits=True) Predict continuous output for input X. .. py:class:: OrdinalLogisticLoss(num_classes) Bases: :py:obj:`torch.nn.Module` .. py:attribute:: num_classes .. py:attribute:: breakpoints .. py:method:: _compute_probabilities(logits) Compute class probabilities .. py:method:: forward(logits, targets) Compute loss more efficiently but maintaining numerical equivalence. .. py:method:: get_pred_probs(logits) Predict most likely class.