Raise red flags on machine learning datasets.
Project description
Redflag
🚩 redflag
aims to be an automatic safety net for machine learning datasets. The vision is to accept input of a Pandas DataFrame
or NumPy ndarray
(one for each of the input X
and target y
in a machine learning task). redflag
will provide an analysis of each feature, and of the target, including aspects such as class imbalance, leakage, outliers, anomalous data patterns, threats to the IID assumption, and so on. The goal is to complement other projects like pandas-profiling
and greatexpectations
.
Installation
You can install this package with pip
:
pip install redflag
For developers, there is a pip
option for installing dev
dependencies. Use pip install redflag[dev]
to install all testing and documentation packages.
Example
The most useful components of redflag
are probably the scikit-learn
"detectors". These sit in your pipeline, look at your training and validation data, and emit warnings if something looks like it might cause a problem. For example, if we
redflag
is mostly a collection of functions. Most of the useful ones take one or more columns of data (usually a 1D or 2D NumPy array) and run a single test. For example, we can do some outlier detection. The get_outliers()
function returns the indices of data points that are considered outliers:
>>> import redflag as rf
>>> data = 3 * [-3, -2, -2, -1, 0, 0, 0, 1, 2, 2, 3]
>>> rf.get_outliers(data)
array([], dtype=int64)
That is, there are no outliers. But let's add a clear outlier: a new data record with a value of 100. The function returns the index position(s) of the outlier point(s):
>>> rf.get_outliers(data + [100])
array([33])
See the documentation, and specifically the notebook Basic_usage.ipynb for several other basic examples.
Documentation
Contributing
Please see CONTRIBUTING.md
. There is also a section in the documentation about Development.
Testing
You can run the tests (requires pytest
and pytest-cov
) with
pytest
Most of the tests are doctests, but pytest
will run them using the settings in pyproject.toml
.
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
Hashes for redflag-0.3.0rc0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18852f1a2c7e9c174f5a04bd1686c7dd0369d0ba031829e210652e36fcae325b |
|
MD5 | f4926f6e7eb46b518642466b96bc786f |
|
BLAKE2b-256 | a3aaf0e450bf87c0cc04c252f0e2f10c27d728cb5c4fda996702978c030d2279 |