Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanRosenthal committed Dec 6, 2018
1 parent dd491ce commit e2e06db
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 18 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
@@ -0,0 +1,10 @@
language: python
python:
- "3.6"
# command to install dependencies
install:
- pip install -r requirements.txt
- pip install -r test-requirements.txt
# command to run tests
script:
- pytest tests/
16 changes: 8 additions & 8 deletions README.md
@@ -1,6 +1,6 @@
# medallion
# spacecutter

`medallion` is a library for implementing ordinal regression models in PyTorch. The library consists of models and loss functions. It is recommended to use [skorch](http://skorch.readthedocs.io/) to wrap the models to make them compatible with scikit-learn.
`spacecutter` is a library for implementing ordinal regression models in PyTorch. The library consists of models and loss functions. It is recommended to use [skorch](http://skorch.readthedocs.io/) to wrap the models to make them compatible with scikit-learn.

## Installation

Expand All @@ -14,14 +14,14 @@ pip install -e .

### Models

Define any PyTorch model you want that generates a single, scalar prediction value. This will be our `predictor` model. This model can then be wrapped with `medallion.models.OrdinalLogisticModel` which will convert the output of the `predictor` from a single number to an array of ordinal class probabilities. The following example shows how to do this for a two layer neural network `predictor` for a problem with three ordinal classes.
Define any PyTorch model you want that generates a single, scalar prediction value. This will be our `predictor` model. This model can then be wrapped with `spacecutter.models.OrdinalLogisticModel` which will convert the output of the `predictor` from a single number to an array of ordinal class probabilities. The following example shows how to do this for a two layer neural network `predictor` for a problem with three ordinal classes.

```python
import numpy as np
import torch
from torch import nn

from medallion.models import OrdinalLogisticModel
from spacecutter.models import OrdinalLogisticModel


X = np.array([[0.5, 0.1, -0.1],
Expand Down Expand Up @@ -54,13 +54,13 @@ print(y_pred)

### Training

It is recommended to use [skorch](http://skorch.readthedocs.io/) to train `medallion` models. The following shows how to train the model from the previous section using cumulative link loss with `skorch`:
It is recommended to use [skorch](http://skorch.readthedocs.io/) to train `spacecutter` models. The following shows how to train the model from the previous section using cumulative link loss with `skorch`:

```python
from skorch import NeuralNet

from medallion.callbacks import AscensionCallback
from medallion.losses import CumulativeLinkLoss
from spacecutter.callbacks import AscensionCallback
from spacecutter.losses import CumulativeLinkLoss

skorch_model = NeuralNet(
module=OrdinalLogisticModel,
Expand All @@ -77,4 +77,4 @@ skorch_model.fit(X, y)

```

Note that we must add the `AscensionCallback`. This ensures that the ordinal cutpoints stay in ascending order. While ideally this constraint would be factored directly into the model optimization, `medallion` currently hacks an SGD-compatible solution by utilizing a post-backwards-pass callback to clip the cutpoint values.
Note that we must add the `AscensionCallback`. This ensures that the ordinal cutpoints stay in ascending order. While ideally this constraint would be factored directly into the model optimization, `spacecutter` currently hacks an SGD-compatible solution by utilizing a post-backwards-pass callback to clip the cutpoint values.
6 changes: 3 additions & 3 deletions setup.py
@@ -1,7 +1,7 @@
import os
from setuptools import setup, find_packages

from medallion import __version__
from spacecutter import __version__


here = os.path.abspath(os.path.dirname(__file__))
Expand All @@ -17,12 +17,12 @@


setup(
name='medallion',
name='spacecutter',
version=__version__,
description='Ordinal regression models in PyTorch',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/EthanRosenthal/medallion',
url='https://github.com/EthanRosenthal/spacecutter',
author='Ethan Rosenthal',
author_email='ethanrosenthal@gmail.com',
classifiers=[
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion medallion/callbacks.py → spacecutter/callbacks.py
@@ -1,7 +1,7 @@
from skorch.callbacks import Callback
from torch.nn import Module

from medallion.models import LogisticCumulativeLink
from spacecutter.models import LogisticCumulativeLink


class AscensionCallback(Callback):
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/test_callbacks.py
@@ -1,8 +1,8 @@
import torch
from torch import nn

from medallion import callbacks
from medallion.models import OrdinalLogisticModel
from spacecutter import callbacks
from spacecutter.models import OrdinalLogisticModel


def test_clip_ensures_sorted_cutpoints():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_losses.py
Expand Up @@ -2,7 +2,7 @@
import pytest
import torch

from medallion import losses
from spacecutter import losses


class Test_reduction:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_models.py
Expand Up @@ -3,9 +3,9 @@
import torch
from torch import nn

from medallion.callbacks import AscensionCallback
from medallion.losses import CumulativeLinkLoss
from medallion.models import OrdinalLogisticModel
from spacecutter.callbacks import AscensionCallback
from spacecutter.losses import CumulativeLinkLoss
from spacecutter.models import OrdinalLogisticModel


SEED = 666
Expand Down

0 comments on commit e2e06db

Please sign in to comment.