You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that we can pick a value for $\alpha$ such that the confusion matrix is balanced. there's also a modest increase in accuracy for this balancing moment.
295
295
296
296
It should be emphasized though that this feature is **experimental**. There have been dataset/model combinations where this effect seems to work very well while there have also been situations where this trick does not work at all.
Ordinal classification (sometimes also referred to as Ordinal Regression) involves predicting an ordinal target variable, where the classes have a meaningful order.
387
+
Examples of this kind of problem are: predicting customer satisfaction on a scale from 1 to 5, predicting the severity of a disease, predicting the quality of a product, etc.
388
+
389
+
The [`OrdinalClassifier`][ordinal-classifier-api] is a meta-model that can be used to transform any classifier into an ordinal classifier by fitting N-1 binary classifiers, each handling a specific class boundary, namely: $P(y <= 1), P(y <= 2), ..., P(y <= N-1)$.
390
+
391
+
This implementation is based on the paper [A simple approach to ordinal classification][ordinal-classification-paper] and it allows to predict the ordinal probabilities of each sample belonging to a particular class.
392
+
393
+
??? tip "Graphical representation"
394
+
An image (from the paper itself) is worth a thousand words:
Description of the dataset from [statsmodels tutorial][statsmodels-ordinal-regression]:
407
+
408
+
> This dataset is about the probability for undergraduate students to apply to graduate school given three exogenous variables:
409
+
>
410
+
> - their grade point average (`gpa`), a float between 0 and 4.
411
+
> -`pared`, a binary that indicates if at least one parent went to graduate school.
412
+
> -`public`, a binary that indicates if the current undergraduate institution of the student is > public or private.
413
+
>
414
+
> `apply`, the target variable is categorical with ordered categories: "unlikely" < "somewhat likely" < "very likely".
415
+
>
416
+
> [...]
417
+
>
418
+
> For more details see the the Documentation of OrderedModel, [the UCLA webpage][ucla-webpage].
419
+
420
+
The only transformation we are applying to the data is to convert the target variable to an ordinal categorical variable by mapping the ordered categories to integers using their (pandas) category codes.
421
+
422
+
We are now ready to train a [`OrdinalClassifier`][ordinal-classifier-api] on this dataset:
The `OrdinalClassifier` emphasizes the importance of proper probability estimates for its functionality. It is recommended to use the [`CalibratedClassifierCV`][calibrated-classifier-api] class from scikit-learn to calibrate the probabilities of the binary classifiers.
433
+
434
+
Probability calibration is _not_ enabled by default, but we provide a convenient keyword argument `use_calibration` to enable it as follows:
435
+
436
+
```py title="OrdinalClassifier with probability calibration"
As a meta-estimator, the `OrdinalClassifier` fits N-1 binary classifiers, which may be computationally expensive, especially with a large number of samples, features, or a complex classifier.
0 commit comments