Skip to main content

KS Metric

Kolmogorov-Smirnov metric (ks metric) is derived from K-S test. K-S test measures the distance between two plotted cumulative distribution functions (CDF). To use it as a metric for classification machine learning problem we see the distance of plotted CDF of target and non-target. The model that produces the greatest amount of separability between target and non-target distribution would be considered the better model.

Installation

The package requires: pandas and numpy.

To install the package, execute:

$ python setup.py install

or

pip install ks_metric

Usage

To get the KS score :

from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression

from ks_metric import ks_score

data = load_breast_cancer()
X, y = data['data'], data['target']
X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.33, random_state=42)

clf = LogisticRegression(random_state=0, max_iter=10000).fit(X_train, y_train)
ks_score(y_train, clf.predict_proba(X_train)[:,1])

KS table :

from ks_metric import ks_table

ks_table(y_train, clf.predict_proba(X_train)[:,1])

KS scorer (for hyperparameter search) :

from sklearn.model_selection import GridSearchCV
from ks_metric import ks_scorer

clf = GridSearchCV(estimator=LogisticRegression(), param_grid={'C':[0.01,0.1,1]}, scoring=ks_scorer)

see the example notebook for detailed usage.

Metadata

Release files for ks-metric 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ks-metric 0.2.0
File Size Uploaded Provenance Actions
ks_metric-0.2.0.tar.gz 10.7 kB Without provenance Details for ks_metric-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ks-metric 0.2.0
File Interpreter ABI Platform Actions
ks_metric-0.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for ks_metric-0.2.0-py2.py3-none-any.whl

Total release size: 15.2 kB

Release files / ks_metric-0.2.0.tar.gz

Download URL ks_metric-0.2.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ce2862c87c00a011611ea23f12fd3399a424cfb6324df932149697ffe1992f87
BLAKE2b-256 checksum
How to use checksums
a2af305f8b091e19e504e97478e87e8753f29b7962d6a0682b32d273646a1f1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.12

Release files / ks_metric-0.2.0-py2.py3-none-any.whl

Download URL ks_metric-0.2.0-py2.py3-none-any.whl
Size 4.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
573373321eb11659b96bed5591457da3951692e3207340aa73a7bb9b8d251a30
BLAKE2b-256 checksum
How to use checksums
4cf96d6a291a10ecb9b3e9af83187782aa7622084fc78f91185e9acb98b9e7b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.12

Security for ks-metric 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page