Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Commit 529ef1c

Browse files
authored
Merge pull request #334 from credo-ai/release/1.1.8
Release/1.1.8
2 parents 8da1944 + 4c4190a commit 529ef1c

35 files changed

+1006
-225
lines changed

.github/workflows/black.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v3
1010
- uses: psf/black@stable
1111
with:
1212
version: "22.10.0"

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
runs-on: ubuntu-20.04
1010

1111
steps:
12-
- uses: actions/checkout@v2
13-
- uses: actions/setup-python@v2
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-python@v4
1414
- name: Install dependencies
1515
run: |
1616
python -m pip install --upgrade pip
@@ -21,4 +21,4 @@ jobs:
2121
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
2222
run: |
2323
python setup.py sdist bdist_wheel
24-
twine upload dist/*
24+
twine upload dist/*

.github/workflows/test.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ on:
1313
jobs:
1414
run-test:
1515
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: ["3.7", "3.8", "3.9", "3.10"]
1619
steps:
1720
- name: Check out repository
18-
uses: actions/checkout@v2
19-
- name: Set up python
20-
uses: actions/setup-python@v2
21+
uses: actions/checkout@v3
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v4
2124
with:
22-
python-version: 3.8
25+
python-version: ${{ matrix.python-version }}
26+
cache: 'pip'
2327
- name: Install dependencies
2428
run: |
2529
python -m pip install --upgrade pip
@@ -36,12 +40,13 @@ jobs:
3640
set -o pipefail
3741
scripts/test.sh | tee ./pytest-coverage.txt
3842
- name: my-artifact
39-
if: always()
43+
if: always() && !env.ACT
4044
uses: actions/upload-artifact@v3
4145
with:
4246
name: pytest-coverage
4347
path: ./pytest-coverage.txt
4448
- name: Pytest coverage comment
49+
if: always() && !env.ACT
4550
uses: MishaKav/pytest-coverage-comment@main
4651
with:
4752
pytest-coverage-path: ./pytest-coverage.txt

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ The latest stable release (and required dependencies) can be installed from PyPI
3737
pip install credoai-lens
3838
```
3939

40-
Additional installation instructions can be found in our [setup documentation](https://credoai-lens.readthedocs.io/en/stable/notebooks/quickstart.html)
40+
Additional installation instructions can be found in our [setup documentation](https://credoai-lens.readthedocs.io/en/stable/pages/setup.html)
4141

4242
## Getting Started
43-
4443
To get started, see the [quickstart demo](https://credoai-lens.readthedocs.io/en/stable/notebooks/quickstart.html).
4544

4645
If you are using the Credo AI Governance App, also check out the [governance integration demo](https://credoai-lens.readthedocs.io/en/stable/notebooks/governance_integration.html).

credoai/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# 1) we don't load dependencies by storing it in __init__.py
33
# 2) we can import it in setup.py for the same reason
44
# 3) we can import it into your module module
5-
__version__ = "1.1.7"
5+
__version__ = "1.1.8"

credoai/artifacts/data/base_data.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from copy import deepcopy
55
from typing import Optional, Union
66

7-
import pandas as pd
87
import numpy as np
8+
import pandas as pd
99

1010
from credoai.utils import global_logger
1111
from credoai.utils.common import ValidationError, check_pandas
@@ -218,7 +218,7 @@ def _validate_processed_y(self):
218218

219219
def _validate_processed_sensitive(self):
220220
"""Validation of processed sensitive features"""
221-
for col_name, col in self.sensitive_features.iteritems():
221+
for col_name, col in self.sensitive_features.items():
222222
# validate unique
223223
unique_values = col.unique()
224224
if len(unique_values) == 1:
@@ -227,16 +227,16 @@ def _validate_processed_sensitive(self):
227227
f"than one unique value. Only found one value: {unique_values[0]}"
228228
)
229229
# validate number in each group
230-
for group, value in col.value_counts().iteritems():
230+
for group, value in col.value_counts().items():
231231
if value < 10:
232232
global_logger.warning(
233233
f"Dataset Issue! Very few ({value}) records were found for {group} under sensitive feature {col_name}."
234234
)
235235
# validate variance in y
236236
if self.y is not None:
237237
y = pd.DataFrame(self.y)
238-
for outcome, outcome_col in y.iteritems():
239-
for group, value in outcome_col.groupby(col).nunique().iteritems():
238+
for outcome, outcome_col in y.items():
239+
for group, value in outcome_col.groupby(col).nunique().items():
240240
if not np.all(value):
241241
global_logger.warning(
242242
"%s\n%s",

credoai/evaluators/data_fairness.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,26 @@ class DataFairness(Evaluator):
4444
- group differences of features
4545
- evaluates whether features in the dataset are proxies for the sensitive feature
4646
- whether the entire dataset can be seen as a proxy for the sensitive feature
47-
(i.e., the sensitive feature is "redundantly encoded")
47+
(i.e., the sensitive feature is "redundantly encoded")
48+
49+
Required Artifacts
50+
------------------
51+
**Required Artifacts**
52+
53+
Generally artifacts are passed directly to :class:`credoai.lens.Lens`, which
54+
handles evaluator setup. However, if you are using the evaluator directly, you
55+
will need to pass the following artifacts when instantiating the evaluator:
56+
57+
- data: :class:`credoai.artifacts.TabularData`
58+
The data to evaluate, which must include a sensitive feature
4859
4960
Parameters
5061
----------
5162
categorical_features_keys : list[str], optional
5263
Names of the categorical features
5364
categorical_threshold : float
5465
Parameter for automatically identifying categorical columns. See
55-
`credoai.utils.common.is_categorical`
66+
:class:`credoai.utils.common.is_categorical` for more details.
5667
"""
5768

5869
required_artifacts = {"data", "sensitive_feature"}
@@ -62,7 +73,6 @@ def __init__(
6273
categorical_features_keys: Optional[List[str]] = None,
6374
categorical_threshold: float = 0.05,
6475
):
65-
6676
self.categorical_features_keys = categorical_features_keys
6777
self.categorical_threshold = categorical_threshold
6878
super().__init__()
@@ -220,7 +230,7 @@ def _find_categorical_features(self, threshold):
220230
if is_categorical(self.sensitive_features, threshold=threshold):
221231
self.sensitive_features = self.sensitive_features.astype("category")
222232
cat_cols = []
223-
for name, column in self.X.iteritems():
233+
for name, column in self.X.items():
224234
if is_categorical(column, threshold=threshold):
225235
cat_cols.append(name)
226236
return cat_cols

credoai/evaluators/data_profiler.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from credoai.utils.common import ValidationError, check_pandas
1212

1313
backend = matplotlib.get_backend()
14-
# load pands profiler, which sets backend to Agg
15-
from pandas_profiling import ProfileReport
14+
# load ydata profiler, which sets backend to Agg
15+
from ydata_profiling import ProfileReport
1616

1717
matplotlib.use(backend)
1818

@@ -29,7 +29,16 @@ class DataProfiler(Evaluator):
2929
Parameters
3030
----------
3131
profile_kwargs
32-
Potential arguments to be passed to pandas_profiling.ProfileReport
32+
Potential arguments to be passed to ydata_profiling.ProfileReport
33+
34+
Required Artifacts
35+
------------------
36+
Generally artifacts are passed directly to :class:`credoai.lens.Lens`, which
37+
handles evaluator setup. However, if you are using the evaluator directly, you
38+
will need to pass the following artifacts when instantiating the evaluator:
39+
40+
data : TabularData
41+
The data to evaluate, which must include a sensitive feature
3342
"""
3443

3544
required_artifacts = {"data"}

credoai/evaluators/deepchecks_credoai.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ class Deepchecks(Evaluator):
2727
be used in preference to deepchecks, since output formats of other evaluators is generally
2828
consistent, while this deepchecks evaluator outputs results in a highly structured JSON format.
2929
30+
Required Artifacts
31+
------------------
32+
**Required Artifacts**
33+
34+
Generally artifacts are passed directly to :class:`credoai.lens.Lens`, which
35+
handles evaluator setup. However, if you are using the evaluator directly, you
36+
will need to pass **at least one** of the following artifacts when instantiating the evaluator:
37+
38+
- model: :class:`credoai.artifacts.Model` or :class:`credoai.artifacts.RegressionModel`
39+
- assessment_data: :class:`credoai.artifacts.TabularData`
40+
The assessment data to evaluate. Assessment data is used to calculate metrics
41+
on the model.
42+
- training_data: :class:`credoai.artifacts.TabularData`
43+
The training data to evaluate. The training data was used to tran the model
44+
3045
3146
Parameters
3247
----------

credoai/evaluators/equity.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ class DataEquity(Evaluator):
2626
- Proportion (Bounded [0-1] continuous outcome): outcome is transformed to logits, then
2727
proceed as normal for continuous
2828
29+
Required Artifacts
30+
------------------
31+
**Required Artifacts**
32+
33+
Generally artifacts are passed directly to :class:`credoai.lens.Lens`, which
34+
handles evaluator setup. However, if you are using the evaluator directly, you
35+
will need to pass the following artifacts when instantiating the evaluator:
36+
37+
- data: :class:`credoai.artifacts.TabularData`
38+
The data to evaluate for equity (based on the outcome variable). Must
39+
have sensitive feature defined.
40+
41+
2942
Parameters
3043
----------
3144
p_value : float
@@ -190,14 +203,28 @@ class ModelEquity(DataEquity):
190203
Evaluates the equity of a model's predictions.
191204
192205
This evaluator assesses whether model predictions are distributed equally across a sensitive
193-
feature. Depending on the kind of outcome, different tests will be performed.
206+
feature. Depending on the kind of outcome, different tests will be performed:
194207
195-
* Discrete: chi-squared contingency tests,
208+
- Discrete: chi-squared contingency tests,
196209
followed by bonferronni corrected posthoc chi-sq tests
197-
* Continuous: One-way ANOVA, followed by Tukey HSD posthoc tests
198-
* Proportion (Bounded [0-1] continuous outcome): outcome is transformed to logits, then
210+
- Continuous: One-way ANOVA, followed by Tukey HSD posthoc tests
211+
- Proportion (Bounded [0-1] continuous outcome): outcome is transformed to logits, then
199212
proceed as normal for continuous
200213
214+
Required Artifacts
215+
------------------
216+
**Required Artifacts**
217+
218+
Generally artifacts are passed directly to :class:`credoai.lens.Lens`, which
219+
handles evaluator setup. However, if you are using the evaluator directly, you
220+
will need to pass the following artifacts when instantiating the evaluator:
221+
222+
- model: :class:`credoai.artifacts.Model`
223+
- assessment_data: :class:`credoai.artifacts.TabularData`
224+
The assessment data to use to create model predictions and evaluate
225+
the equity of the model. Must have sensitive features.
226+
227+
201228
Parameters
202229
----------
203230
use_predict_proba : bool, optional

0 commit comments

Comments
 (0)