Skip to main content

An Python implementation for Snell scoring

Project description

Snell Scoring Module

This module provides an implementation of the Snell scoring method for ordered categorical data. It includes functionality to compute scores based on a frequency table and standardize the results to a 0-100 scale if needed.

Installation

To use the module, clone the repository and install the necessary dependencies:

git clone git@github.com:IgorekLoschinin/snellscore.git
cd .\snellscore
pip install -r requirements.txt

or

pip install snellscore

Usage

Import the Module

from snellscore import Snell
import pandas as pd

Prepare the Frequency Table

The input should be a pandas DataFrame where rows represent groups and columns represent categories.

# Example frequency table
data = {
    "Category1": [0, 6, 0, 0, 0, 2, 3, 0, 1, 2, 0, 5],
    "Category2": [0, 3, 0, 4, 0, 4, 4, 0, 2, 2, 0, 1],
    "Category3": [0, 1, 3, 1, 0, 3, 3, 1, 0, 2, 0, 1],
    "Category4": [3, 0, 2, 2, 0, 1, 0, 1, 0, 0, 0, 0],
    "Category5": [3, 1, 2, 4, 2, 0, 1, 1, 1, 2, 4, 1],
    "Category6": [2, 1, 4, 0, 5, 2, 1, 5, 4, 4, 1, 3],
    "Category7": [4, 0, 1, 1, 5, 0, 0, 4, 4, 0, 7, 1]
}
frequency_table = pd.DataFrame(data, index=[f"Group{item}" for item in range(1, 13)])

Initialize the Snell Object

Create an instance of the Snell class, optionally enabling score standardization.

snell = Snell(standard=True)

Run the Scoring Method

Pass the frequency table to the run method.

snell.run(frequency_table)

Retrieve the Scores

Get the calculated scores and standardized scores (if enabled):

# Get the calculated scores
scores = snell.score
print("Calculated Scores:")
print(scores)

# Get the standardized scores (0-100 scale)
standardized_scores = snell.score_standard
print("Standardized Scores:")
print(standardized_scores)

Output Example

For the example frequency table, the output might look like:

Snell Scores:
Category0   -1.072418
Category1    0.611888
Category2    1.602323
Category3    2.186739
Category4    2.837535
Category5    4.012972
Category6    5.850891
dtype: float64

Standardized Scores:
Category0      0
Category1     24
Category2     39
Category3     47
Category4     56
Category5     73
Category6    100
dtype: Int16

Testing

To run tests for the module, use pytest:

pytest tests/

References

  1. https://www.icar.org/Guidelines/07.6-Functional-traits-Calving-Traits-in-Dairy-Cattle.pdf
  2. https://cdnsciencepub.com/doi/pdf/10.4141/cjas77-001
  3. https://www.jstor.org/stable/2528498?origin=JSTOR-pdf
  4. https://github.com/pfpetrowski/rsnell

License

This project is licensed under the GNU General Public License. See the LICENSE file for details.

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

snellscore-1.1.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

snellscore-1.1.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file snellscore-1.1.0.tar.gz.

File metadata

  • Download URL: snellscore-1.1.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for snellscore-1.1.0.tar.gz
Algorithm Hash digest
SHA256 89cde598d72684998374f60fb81b881016f3e5ef1d79391fd46a9e322aeddbd1
MD5 ed2281c6966e7898b02f8d4cde1fa68f
BLAKE2b-256 3003ceb73cd985af4c8f9f7e19d81a827d93699a37bddd8ac69c04bff8c6ab5d

See more details on using hashes here.

File details

Details for the file snellscore-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: snellscore-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for snellscore-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6ac8d8c3cb3f08263e358f44b32ef7f0ed85c39c7d6169bf11f5b1f3a2ae0c37
MD5 472ae78409841897e84830a6a191a3d6
BLAKE2b-256 881937cf5dc31fa703b4e36ea7e30d42eb932767accee9caec7025be436d3a5b

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