That is from the spacecutter library

  
      
      GitHub
  
  
    

EthanRosenthal/spacecutter 1

Ordinal regression models in PyTorch. Contribute to EthanRosenthal/spacecutter development by creating an account on GitHub.


  
  
    
    
  
  


from skorch import NeuralNet
import numpy as np
import torch
from torch import nn
from sklearn.model_selection import train_test_split
from spacecutter.callbacks import AscensionCallback
from spacecutter.losses import CumulativeLinkLoss
from spacecutter.models import OrdinalLogisticModel
predictor = nn.Sequential(
nn.Linear(num_features, num_features),
nn.ReLU(),
nn.Linear(num_features, 1)
)
from skorch.net import NeuralNet
skorch_model = NeuralNet(
module=OrdinalLogisticModel,
module__predictor=predictor,
module__num_classes=num_classes,
criterion=CumulativeLinkLoss,
train_split=None,
callbacks=[
(‘ascension’, AscensionCallback()),
],
)