Metadata-Version: 2.4
Name: complyai
Version: 0.2.0
Summary: Shift-left compliance for AI – local, private, no cloud.
Author-email: Patrik Redo <patrikredo@gmail.com>
License: Apache-2.0
Keywords: AI,compliance,bias,EU AI Act,fairness,audit
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: pandas>=2.0
Requires-Dist: holisticai>=1.0
Requires-Dist: streamlit>=1.35
Requires-Dist: plotly>=5.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: ruff; extra == "dev"

# ComplAInce ⚖️

**Local, private, no-cloud AI compliance auditing.**

ComplAInce is a CLI tool and Streamlit report viewer that helps you detect bias in your models and classify your AI system under the **EU AI Act (2024/1689)** – entirely on your own machine, no data leaves your environment.

---

## ⚡ Quick start

```bash
pip install complyai
```

```bash
complyai scan \
  --path data.csv \
  --protected-col gender \
  --label-col hired \
  --pred-col model_prediction \
  --use-case employment
```

```
Scanning data.csv ...

EU AI Act Risk Level: 🟠 HIGH
  High-risk – Employment & worker management (recruitment, promotion, termination)
  Reference: Annex III §4

Top 3 Bias Metrics:
  - 2SD Rule: -5.5932
  - Disparate Impact: 0.5997
  - Four Fifths Rule: 0.5997

Rows analysed: 500
Protected attribute groups: 0 vs 1

Report saved to: ./audit_report_2026-04-22_13-28-15.json
```

Then open the report in the interactive viewer:

```bash
complyai-ui
# → http://localhost:8501
```

---

## 🔧 Installation

**Requirements:** Python 3.11+

```bash
pip install complyai
```

For development:

```bash
git clone https://github.com/patrikredo/complyai
cd complyai
pip install -e ".[dev]"
```

---

## 🚀 CLI reference

### `complyai scan`

```
complyai scan --path <CSV> [options]

Arguments:
  --path           Path to the dataset CSV file                  (required)
  --protected-col  Column for the protected attribute            (default: gender)
  --label-col      Column for the ground-truth label             (default: hired)
  --pred-col       Column for the model prediction               (default: model_prediction)
  --use-case       EU AI Act use-case category                   (default: other)
  --simulate       Use dummy data – no CSV needed, for testing
```

### `complyai-ui`

Launches the Streamlit report viewer at `http://localhost:8501`. Upload any `audit_report_*.json` to explore results interactively.

---

## 🗂️ Use-case categories

| `--use-case`           | Risk level   | Typical applications                          |
|------------------------|-------------|-----------------------------------------------|
| `biometric`            | PROHIBITED  | Real-time biometric surveillance              |
| `social_scoring`       | PROHIBITED  | Social scoring by public authorities          |
| `law_enforcement`      | HIGH        | Predictive policing, evidence assessment      |
| `employment`           | HIGH        | Recruitment, promotion, termination           |
| `credit`               | HIGH        | Credit scoring, insurance pricing             |
| `education`            | HIGH        | Admission, assessment, monitoring             |
| `healthcare`           | HIGH        | Clinical decision support                     |
| `critical_infrastructure` | HIGH     | Energy, water, transport safety               |
| `migration`            | HIGH        | Asylum, border control                        |
| `chatbot`              | LIMITED     | Virtual agents, customer service bots         |
| `recommendation`       | LIMITED     | Content personalisation                       |
| `other`                | MINIMAL     | Low-risk general-purpose AI                   |

---

## 📊 Bias metrics (via holisticai)

| Metric                              | Reference | Interpretation                         |
|-------------------------------------|-----------|----------------------------------------|
| Statistical Parity                  | 0         | Difference in positive prediction rates |
| Disparate Impact                    | 1         | Ratio of positive rates (< 0.8 = bias) |
| Four Fifths Rule                    | 1         | Regulatory 80% rule (EEOC)             |
| Cohen D                             | 0         | Standardised effect size               |
| Equality of Opportunity Difference  | 0         | Difference in true positive rates      |
| False Positive Rate Difference      | 0         | Difference in false positive rates     |
| Average Odds Difference             | 0         | Average of TPR + FPR differences       |
| Accuracy Difference                 | 0         | Difference in accuracy between groups  |

---

## 📁 Report format

Reports are saved as `audit_report_<timestamp>.json`:

```json
{
  "metadata": {
    "timestamp": "2026-04-22T13:28:15",
    "scanned_file": "data.csv",
    "tool_version": "complyai 0.2.0",
    "python_environment": { "version": "3.11.x", "os": "Darwin" },
    "simulated": false
  },
  "eu_ai_act": {
    "use_case": "employment",
    "risk_level": "HIGH",
    "article": "Annex III §4",
    "classification": "High-risk – Employment & worker management",
    "obligations": ["Conformity assessment required before deployment.", "..."]
  },
  "bias_analysis": {
    "protected_column": "gender",
    "label_column": "hired",
    "prediction_column": "model_prediction",
    "rows_analysed": 500,
    "group_a": "0",
    "group_b": "1",
    "metrics": {
      "Statistical Parity": -0.2515,
      "Disparate Impact": 0.5997
    }
  }
}
```

---

## 🏗️ Project structure

```
complyai/
├── cli.py            # complyai scan entry point
├── eu_act.py         # Rule-based EU AI Act Annex III classifier
└── streamlit_app.py  # complyai-ui report viewer
```

---

## 📜 License

[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
