ogboost.StatsModelsOrderedModel

class ogboost.StatsModelsOrderedModel(distr='probit', fit_method='bfgs', fit_disp=False, fit_maxiter=500)[source]

Bases: BaseEstimator, ClassifierMixin

A basic scikit-learn wrapper for statsmodels’ OrderedModel (linear ordinal regression).

This wrapper adapts the OrderedModel to the scikit-learn API, allowing it to be used with standard model selection tools such as cross_val_score.

Parameters:
  • distr (str, default='probit') – The distribution used in the OrderedModel (e.g., ‘probit’ or ‘logit’).

  • fit_method (str, default='bfgs') – The optimization method to use when fitting the model.

  • fit_disp (bool, default=False) – Whether to display convergence messages during fitting.

  • fit_maxiter (int, default=500) – The maximum number of iterations to use during fitting.

Variables:
  • model (OrderedModel instance) – The underlying OrderedModel created during fit.

  • res (Results instance) – The fitted results from OrderedModel.

__init__(distr='probit', fit_method='bfgs', fit_disp=False, fit_maxiter=500)[source]

Methods

__init__([distr, fit_method, fit_disp, ...])

decision_function(X)

Compute the latent function (linear predictor) for X.

fit(X, y)

Fit the ordered model using the provided training data.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict(X)

Predict class labels for X by selecting the class with the highest probability.

predict_proba(X)

Predict class probabilities for X.

score(X, y[, sample_weight])

Compute the performance of the model using the concordance index on the latent scores.

set_params(**params)

Set the parameters of this estimator.

set_score_request(*[, sample_weight])

Configure whether metadata should be requested to be passed to the score method.

fit(X, y)[source]

Fit the ordered model using the provided training data.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Training data.

  • y (array-like of shape (n_samples,)) – Ordinal target values.

Returns:

self (object) – Returns self.

predict_proba(X)[source]

Predict class probabilities for X.

Parameters:

X (array-like of shape (n_samples, n_features)) – Input data.

Returns:

probas (ndarray of shape (n_samples, n_classes)) – The predicted class probabilities.

decision_function(X)[source]

Compute the latent function (linear predictor) for X.

Parameters:

X (array-like of shape (n_samples, n_features)) – Input data.

Returns:

latent_scores (ndarray of shape (n_samples,)) – The latent function values.

predict(X)[source]

Predict class labels for X by selecting the class with the highest probability.

Parameters:

X (array-like of shape (n_samples, n_features)) – Input data.

Returns:

labels (ndarray of shape (n_samples,)) – Predicted ordinal class labels.

score(X, y, sample_weight=None)[source]

Compute the performance of the model using the concordance index on the latent scores.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Input data.

  • y (array-like of shape (n_samples,)) – True ordinal labels.

  • sample_weight (array-like, optional) – Sample weights for each observation.

Returns:

score (float) – The concordance index computed on the latent function values.

set_score_request(*, sample_weight='$UNCHANGED$')

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
  • sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in score.

  • self (StatsModelsOrderedModel)

Returns:

self (object) – The updated object.

Return type:

StatsModelsOrderedModel