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:
pip install -r requirements.txt
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 1.223775
Category2 2.592759
Category3 3.383042
Category4 4.478767
Category5 6.384713
Category6 5.850891
dtype: float64
Standardized Scores:
Category0 0
Category1 33
Category2 53
Category3 64
Category4 80
Category5 108
Category6 100
dtype: Int16
Testing
To run tests for the module, use pytest:
pytest tests/
References
https://github.com/pfpetrowski/rsnell
License
This project is licensed under the GNU General Public License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snellscore-1.0.0.tar.gz.
File metadata
- Download URL: snellscore-1.0.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.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
123c3985a70d6898a40ccf19e2831904191193508419cd4c58f4023cd12f438b
|
|
| MD5 |
e170ed5c70e18f48569360d90f5a84e6
|
|
| BLAKE2b-256 |
90e54dfdefdf41ec151164dd6e0a85cade3ef1bf73b3b36ad92d51dfe938674c
|
File details
Details for the file snellscore-1.0.0-py3-none-any.whl.
File metadata
- Download URL: snellscore-1.0.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.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c3e2841da27fcc390b8378d99e9818d124dfd425c854b441756be7853cd8401
|
|
| MD5 |
38faba68964ab421d77a72ffe70e9041
|
|
| BLAKE2b-256 |
8e95477ab1b693f50050289d3316898fd801c0f74ee841909720c820b8fe2605
|