Skip to main content

Delightful and useful neural networks models, including OrdinalRegressionLoss, etc.

Project description

handy-nn

Delightful and useful neural networks models, including OrdinalRegressionLoss, etc.

Install

$ pip install handy-nn

Usage

from handy_nn import OrdinalRegressionLoss

# Initialize the loss function
num_classes = 5
criterion = OrdinalRegressionLoss(num_classes)

# For training
logits = model(inputs)  # Shape: (batch_size, 1)
loss = criterion(logits, targets)
loss.backward()

# To get class probabilities
probas = criterion.predict_probas(logits)  # Shape: (batch_size, num_classes)

APIs

OrdinalRegressionLoss(num_classes, learn_thresholds, init_scale)

  • num_classes int: Number of ordinal classes (ranks)
  • learn_thresholds bool=True: Whether to learn threshold parameters or use fixed ones, defaults to True.
  • init_scale float=2.0: Scale for initializing thresholds, defaults to 2.0

Creates the loss function for ordinal regression.

The goal of ordinal regression is to model the relationship between one or more independent variables and an ordinal dependent variable. It predicts the probability that an observation falls into a specific ordinal category or a category higher than a certain threshold. This is particularly useful in fields like social sciences, medicine, and customer surveys where outcomes are often ordinal.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

handy_nn-0.0.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

handy_nn-0.0.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file handy_nn-0.0.2.tar.gz.

File metadata

  • Download URL: handy_nn-0.0.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for handy_nn-0.0.2.tar.gz
Algorithm Hash digest
SHA256 569c2b0c95abb726ea93a47d4e18662484eb6a90f0aab97dbcce57ba694d58c2
MD5 0b263c7486dafe1138f62d61ef851fb5
BLAKE2b-256 2a7954c1a97b1369fd7d4befa8092d66e7cf9908d9741ae340d1d26811114ce0

See more details on using hashes here.

File details

Details for the file handy_nn-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: handy_nn-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for handy_nn-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 556f6da1bc78037bb1e74d6aba230445f0efbd531ea1b8d9878d57fcbd2984f4
MD5 a266c5edffcb00821594103283675cce
BLAKE2b-256 55400edde855fa1b70cb6cdf89bb50764ce8cfa6af289021ce29e8de294ce3e2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page