forked from NGO-Algorithm-Audit/unsupervised-bias-detection
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Krsto Proroković
committed
Feb 29, 2024
1 parent
b295916
commit 50cb2da
Showing
5 changed files
with
72 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,43 @@ | ||
name: Continuous Integration Workflow | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
- dev | ||
push: | ||
branches: | ||
- master | ||
- dev | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
- dev | ||
pull_request: | ||
branches: | ||
- master | ||
- dev | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: install | ||
run: make install | ||
- name: test | ||
run: make test | ||
- name: format | ||
run: make format | ||
- name: lint | ||
run: make lint | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Poetry | ||
run: | | ||
pipx install poetry | ||
poetry config virtualenvs.in-project true | ||
- name: Set Up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
cache: poetry | ||
cache-dependency-path: poetry.lock | ||
|
||
- name: Install Dependencies | ||
run: poetry install --no-root --no-interaction | ||
|
||
- name: Lint | ||
run: poetry run ruff check bias_scan | ||
|
||
- name: Test | ||
run: poetry run pytest | ||
--color=yes | ||
--full-trace | ||
--showlocals | ||
--verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[tool.poetry] | ||
name = "bias-scan" | ||
version = "0.1.0" | ||
description = "" | ||
authors = [] | ||
license = "MIT" | ||
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.11" | ||
numpy = "^1.26.4" | ||
scikit-learn = "^1.4.1.post1" | ||
kmodes = "^0.12.2" | ||
|
||
[tool.poetry.dev-dependencies] | ||
ruff = "^0.2.2" | ||
pytest = "^8.0.2" | ||
|
||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import numpy as np | ||
|
||
from bias_scan.clustering import BiasAwareHierarchicalKMeans | ||
|
||
|
||
def test_clusters(): | ||
# Checks that label values are between 0 and n_clusters | ||
rng = np.random.RandomState(12) | ||
X = rng.rand(10, 5) | ||
y = rng.rand(10) | ||
algo = BiasAwareHierarchicalKMeans(max_iter=3, min_cluster_size=2) | ||
algo.fit(X, y) | ||
assert np.array_equal(np.unique(algo.labels_), np.arange(algo.n_clusters_)) |