ai-critic 1.2.0__py3-none-any.whl → 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ai_critic/ai_suggestions/predictor.py +5 -0
- ai_critic/ai_suggestions/rules.py +3 -0
- ai_critic/cli.py +141 -0
- ai_critic/critic.py +81 -201
- ai_critic/evaluators/config.py +29 -5
- ai_critic/feedback/__init__.py +3 -0
- ai_critic/feedback/store.py +23 -0
- ai_critic/learning/__init__.py +13 -0
- ai_critic/learning/critic_model.py +25 -0
- ai_critic/learning/features.py +15 -0
- ai_critic/learning/policy.py +20 -0
- ai_critic/learning/recommender.py +26 -0
- ai_critic/learning/trainer.py +16 -0
- ai_critic/ml/suggester.py +63 -0
- ai_critic/telemetry/__init__.py +0 -0
- ai_critic/telemetry/anonymizer.py +9 -0
- ai_critic/telemetry/client.py +6 -0
- ai_critic/telemetry/event.py +15 -0
- ai_critic/telemetry/local_store.py +9 -0
- ai_critic/telemetry/schema.py +11 -0
- ai_critic/telemetry/sender.py +9 -0
- ai_critic-2.0.0.dist-info/METADATA +390 -0
- ai_critic-2.0.0.dist-info/RECORD +37 -0
- ai_critic-1.2.0.dist-info/METADATA +0 -290
- ai_critic-1.2.0.dist-info/RECORD +0 -18
- {ai_critic-1.2.0.dist-info → ai_critic-2.0.0.dist-info}/WHEEL +0 -0
- {ai_critic-1.2.0.dist-info → ai_critic-2.0.0.dist-info}/top_level.txt +0 -0
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: ai-critic
|
|
3
|
-
Version: 1.2.0
|
|
4
|
-
Summary: Fast AI evaluator for scikit-learn models
|
|
5
|
-
Author-email: Luiz Seabra <filipedemarco@yahoo.com>
|
|
6
|
-
Requires-Python: >=3.9
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
Requires-Dist: numpy
|
|
9
|
-
Requires-Dist: scikit-learn
|
|
10
|
-
|
|
11
|
-
# ai-critic 🧠: The Quality Gate for Machine Learning Models
|
|
12
|
-
|
|
13
|
-
**ai-critic** is a specialized **decision-making** tool designed to audit the reliability and readiness for deployment of **scikit-learn**, **PyTorch**, and **TensorFlow** models.
|
|
14
|
-
|
|
15
|
-
Instead of merely measuring performance (accuracy, F1 score), **ai-critic** acts as a **Quality Gate**, actively probing the model to uncover *hidden risks* that commonly cause production failures — such as **data leakage**, **structural overfitting**, and **fragility under noise**.
|
|
16
|
-
|
|
17
|
-
> **ai-critic does not ask “How good is this model?”**
|
|
18
|
-
> It asks **“Can this model be trusted?”**
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## 🚀 Getting Started (The Basics)
|
|
23
|
-
|
|
24
|
-
This section is ideal for beginners who need a **fast and reliable verdict** on a trained model.
|
|
25
|
-
|
|
26
|
-
### Installation
|
|
27
|
-
|
|
28
|
-
Install directly from PyPI:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
pip install ai-critic
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
### The Quick Verdict
|
|
37
|
-
|
|
38
|
-
With just a few lines of code, you obtain an **executive-level assessment** and a **deployment recommendation**.
|
|
39
|
-
|
|
40
|
-
```python
|
|
41
|
-
from ai_critic import AICritic
|
|
42
|
-
from sklearn.ensemble import RandomForestClassifier
|
|
43
|
-
from sklearn.datasets import make_classification
|
|
44
|
-
|
|
45
|
-
# 1. Prepare data and model
|
|
46
|
-
X, y = make_classification(n_samples=1000, n_features=20, random_state=42)
|
|
47
|
-
model = RandomForestClassifier(max_depth=5, random_state=42)
|
|
48
|
-
|
|
49
|
-
# 2. Initialize the Critic
|
|
50
|
-
critic = AICritic(model, X, y)
|
|
51
|
-
|
|
52
|
-
# 3. Run the audit (executive mode)
|
|
53
|
-
report = critic.evaluate(view="executive")
|
|
54
|
-
|
|
55
|
-
print(f"Verdict: {report['verdict']}")
|
|
56
|
-
print(f"Risk Level: {report['risk_level']}")
|
|
57
|
-
print(f"Main Reason: {report['main_reason']}")
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
**Expected Output (example):**
|
|
61
|
-
|
|
62
|
-
```text
|
|
63
|
-
Verdict: ⚠️ Risky
|
|
64
|
-
Risk Level: medium
|
|
65
|
-
Main Reason: Structural or robustness-related risks detected.
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
This output is intentionally **conservative**.
|
|
69
|
-
If **ai-critic** recommends deployment, it means meaningful risks were *not* detected.
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## 💡 Understanding the Critique (The Intermediary)
|
|
74
|
-
|
|
75
|
-
For data scientists who want to understand **why** the model received a given verdict and **how to improve it**.
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
### The Four Pillars of the Audit
|
|
80
|
-
|
|
81
|
-
**ai-critic** evaluates models across four independent risk dimensions:
|
|
82
|
-
|
|
83
|
-
| Pillar | Main Risk Detected | Internal Module |
|
|
84
|
-
| ---------------------- | -------------------------------------- | ------------------------ |
|
|
85
|
-
| 📊 **Data Integrity** | Target Leakage & Correlation Artifacts | `evaluators.data` |
|
|
86
|
-
| 🧠 **Model Structure** | Over-complexity & Misconfiguration | `evaluators.config` |
|
|
87
|
-
| 📈 **Performance** | Suspicious CV or Learning Curves | `evaluators.performance` |
|
|
88
|
-
| 🧪 **Robustness** | Sensitivity to Noise | `evaluators.robustness` |
|
|
89
|
-
|
|
90
|
-
Each pillar contributes signals used later in the **deployment gate**.
|
|
91
|
-
|
|
92
|
-
---
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
### Full Technical & Visual Analysis
|
|
96
|
-
|
|
97
|
-
To access **all internal diagnostics**, including plots and recommendations, use `view="all"`.
|
|
98
|
-
|
|
99
|
-
```python
|
|
100
|
-
full_report = critic.evaluate(view="all", plot=True)
|
|
101
|
-
|
|
102
|
-
technical_summary = full_report["technical"]
|
|
103
|
-
|
|
104
|
-
print("\n--- Key Risks Detected ---")
|
|
105
|
-
for i, risk in enumerate(technical_summary["key_risks"], start=1):
|
|
106
|
-
print(f"{i}. {risk}")
|
|
107
|
-
|
|
108
|
-
print("\n--- Recommendations ---")
|
|
109
|
-
for rec in technical_summary["recommendations"]:
|
|
110
|
-
print(f"- {rec}")
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Generated plots may include:
|
|
114
|
-
|
|
115
|
-
* Feature correlation heatmaps
|
|
116
|
-
* Learning curves
|
|
117
|
-
* Robustness degradation charts
|
|
118
|
-
|
|
119
|
-
---
|
|
120
|
-
|
|
121
|
-
### Robustness Test (Noise Injection)
|
|
122
|
-
|
|
123
|
-
A model that collapses under small perturbations is **not production-safe**.
|
|
124
|
-
|
|
125
|
-
```python
|
|
126
|
-
robustness = full_report["details"]["robustness"]
|
|
127
|
-
|
|
128
|
-
print("\n--- Robustness Analysis ---")
|
|
129
|
-
print(f"Original CV Score: {robustness['cv_score_original']:.4f}")
|
|
130
|
-
print(f"Noisy CV Score: {robustness['cv_score_noisy']:.4f}")
|
|
131
|
-
print(f"Performance Drop: {robustness['performance_drop']:.4f}")
|
|
132
|
-
print(f"Verdict: {robustness['verdict']}")
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
**Possible Verdicts:**
|
|
136
|
-
|
|
137
|
-
* `stable` → acceptable degradation
|
|
138
|
-
* `fragile` → high sensitivity to noise
|
|
139
|
-
* `misleading` → performance likely inflated by leakage
|
|
140
|
-
|
|
141
|
-
---
|
|
142
|
-
|
|
143
|
-
## ⚙️ Integration and Governance (The Advanced)
|
|
144
|
-
|
|
145
|
-
This section targets **MLOps engineers**, **architects**, and teams operating automated pipelines.
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
### Multi-Framework Support
|
|
150
|
-
|
|
151
|
-
**ai-critic 1.0+** supports models from multiple frameworks with the **same API**:
|
|
152
|
-
|
|
153
|
-
```python
|
|
154
|
-
# PyTorch Example
|
|
155
|
-
import torch
|
|
156
|
-
import torch.nn as nn
|
|
157
|
-
from ai_critic import AICritic
|
|
158
|
-
|
|
159
|
-
X = torch.randn(1000, 20)
|
|
160
|
-
y = torch.randint(0, 2, (1000,))
|
|
161
|
-
|
|
162
|
-
model = nn.Sequential(
|
|
163
|
-
nn.Linear(20, 32),
|
|
164
|
-
nn.ReLU(),
|
|
165
|
-
nn.Linear(32, 2)
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
critic = AICritic(model, X, y, framework="torch", adapter_kwargs={"epochs":5, "batch_size":64})
|
|
169
|
-
report = critic.evaluate(view="executive")
|
|
170
|
-
print(report)
|
|
171
|
-
|
|
172
|
-
# TensorFlow Example
|
|
173
|
-
import tensorflow as tf
|
|
174
|
-
|
|
175
|
-
model = tf.keras.Sequential([
|
|
176
|
-
tf.keras.layers.Dense(32, activation="relu", input_shape=(20,)),
|
|
177
|
-
tf.keras.layers.Dense(2)
|
|
178
|
-
])
|
|
179
|
-
critic = AICritic(model, X.numpy(), y.numpy(), framework="tensorflow", adapter_kwargs={"epochs":5})
|
|
180
|
-
report = critic.evaluate(view="executive")
|
|
181
|
-
print(report)
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
> No need to rewrite evaluation code — **one Critic API works for sklearn, PyTorch, or TensorFlow**.
|
|
185
|
-
|
|
186
|
-
---
|
|
187
|
-
|
|
188
|
-
### The Deployment Gate (`deploy_decision`)
|
|
189
|
-
|
|
190
|
-
The `deploy_decision()` method aggregates *all detected risks* and produces a final gate decision.
|
|
191
|
-
|
|
192
|
-
```python
|
|
193
|
-
decision = critic.deploy_decision()
|
|
194
|
-
|
|
195
|
-
if decision["deploy"]:
|
|
196
|
-
print("✅ Deployment Approved")
|
|
197
|
-
else:
|
|
198
|
-
print("❌ Deployment Blocked")
|
|
199
|
-
|
|
200
|
-
print(f"Risk Level: {decision['risk_level']}")
|
|
201
|
-
print(f"Confidence Score: {decision['confidence']:.2f}")
|
|
202
|
-
|
|
203
|
-
print("\nBlocking Issues:")
|
|
204
|
-
for issue in decision["blocking_issues"]:
|
|
205
|
-
print(f"- {issue}")
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
**Conceptual model:**
|
|
209
|
-
|
|
210
|
-
* **Hard Blockers** → deployment denied
|
|
211
|
-
* **Soft Blockers** → deployment discouraged
|
|
212
|
-
* **Confidence Score (0–1)** → heuristic trust level
|
|
213
|
-
|
|
214
|
-
---
|
|
215
|
-
|
|
216
|
-
### Modes & Views (API Design)
|
|
217
|
-
|
|
218
|
-
The `evaluate()` method supports **multiple modes** via the `view` parameter:
|
|
219
|
-
|
|
220
|
-
| View | Description |
|
|
221
|
-
| ------------- | ---------------------------------- |
|
|
222
|
-
| `"executive"` | High-level verdict (non-technical) |
|
|
223
|
-
| `"technical"` | Risks & recommendations |
|
|
224
|
-
| `"details"` | Raw evaluator outputs |
|
|
225
|
-
| `"all"` | Complete payload |
|
|
226
|
-
|
|
227
|
-
Example:
|
|
228
|
-
|
|
229
|
-
```python
|
|
230
|
-
critic.evaluate(view="technical")
|
|
231
|
-
critic.evaluate(view=["executive", "performance"])
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
---
|
|
235
|
-
|
|
236
|
-
### Session Tracking & Model Comparison
|
|
237
|
-
|
|
238
|
-
You can persist evaluations and compare model versions over time.
|
|
239
|
-
|
|
240
|
-
```python
|
|
241
|
-
critic_v1 = AICritic(model, X, y, session="v1")
|
|
242
|
-
critic_v1.evaluate()
|
|
243
|
-
|
|
244
|
-
critic_v2 = AICritic(model, X, y, session="v2")
|
|
245
|
-
critic_v2.evaluate()
|
|
246
|
-
|
|
247
|
-
comparison = critic_v2.compare_with("v1")
|
|
248
|
-
print(comparison["score_diff"])
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
This enables:
|
|
252
|
-
|
|
253
|
-
* Regression tracking
|
|
254
|
-
* Risk drift detection
|
|
255
|
-
* Governance & audit trails
|
|
256
|
-
|
|
257
|
-
---
|
|
258
|
-
|
|
259
|
-
### Best Practices & Use Cases
|
|
260
|
-
|
|
261
|
-
| Scenario | Recommended Usage |
|
|
262
|
-
| ----------------------- | -------------------------------------- |
|
|
263
|
-
| **CI/CD** | Block merges using `deploy_decision()` |
|
|
264
|
-
| **Model Tuning** | Use technical view for guidance |
|
|
265
|
-
| **Governance** | Persist session outputs |
|
|
266
|
-
| **Stakeholder Reports** | Share executive summaries |
|
|
267
|
-
|
|
268
|
-
---
|
|
269
|
-
|
|
270
|
-
## 🔒 API Stability
|
|
271
|
-
|
|
272
|
-
Starting from version **1.0.0**, the public API of **ai-critic** follows semantic versioning.
|
|
273
|
-
Breaking changes will only occur in major releases.
|
|
274
|
-
|
|
275
|
-
---
|
|
276
|
-
|
|
277
|
-
## 📄 License
|
|
278
|
-
|
|
279
|
-
Distributed under the **MIT License**.
|
|
280
|
-
|
|
281
|
-
---
|
|
282
|
-
|
|
283
|
-
## 🧠 Final Note
|
|
284
|
-
|
|
285
|
-
> **ai-critic is not a benchmarking tool.**
|
|
286
|
-
> It is a *decision-making system*.
|
|
287
|
-
|
|
288
|
-
A failed audit does **not** mean the model is bad — it means the model **is not ready to be trusted**.
|
|
289
|
-
|
|
290
|
-
The purpose of **ai-critic** is to introduce *structured skepticism* into machine learning workflows — exactly where it belongs.
|
ai_critic-1.2.0.dist-info/RECORD
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
ai_critic/__init__.py,sha256=H6DlPMmbcFUamhsNULPLk9vHx81XCiXuKKf63EJ8eM0,53
|
|
2
|
-
ai_critic/critic.py,sha256=I9MeVHVCN-lWffPm3DJCgbFVVW8VTIs_qhXd-aP3X5Q,8277
|
|
3
|
-
ai_critic/evaluators/__init__.py,sha256=ri6InmL8_LIcO-JZpU_gEFKLO4URdqo3z6rh7fV6M8Y,169
|
|
4
|
-
ai_critic/evaluators/adapters.py,sha256=8Xw9Ccg1iGVNwVQDGVIqhWj5-Sg6evqCZhg21u8EP20,3068
|
|
5
|
-
ai_critic/evaluators/config.py,sha256=gBXaS8Qxl14f40JnvMWgA0Z0SGEtbCuCHpTOPem0H90,1163
|
|
6
|
-
ai_critic/evaluators/data.py,sha256=YAK5NkwCeJOny_UueZ5ALwvEcRDIbEck404eV2oqWnc,1871
|
|
7
|
-
ai_critic/evaluators/explainability.py,sha256=UWbcb5uVI78d1ljfdrWd2DrjlwEz1y9CeVtkukefEfA,1759
|
|
8
|
-
ai_critic/evaluators/performance.py,sha256=1CQx5DueK0XkelYyJnAGRJ3AjQtjsKeW8_1JQZqKVOI,1973
|
|
9
|
-
ai_critic/evaluators/robustness.py,sha256=mfVQ67Z6t6aRvtIq-XQEQYbwvyf8UefM1myeOGVrnAE,1869
|
|
10
|
-
ai_critic/evaluators/scoring.py,sha256=9rgkCXKKm9G1Lfwn5i9HcsJTN5OUjxMycOUzhWkp_2g,1576
|
|
11
|
-
ai_critic/evaluators/summary.py,sha256=H9rU9tXAXqyQ34L6bOOOHrdIapSq71gcjjc8jfyJMq4,5003
|
|
12
|
-
ai_critic/evaluators/validation.py,sha256=rnzRwD78Cugey33gl9geE8JoBURsKEEnqrIOhBZv0LY,904
|
|
13
|
-
ai_critic/sessions/__init__.py,sha256=Yp7mphSPJwt8a4cJgcQNErqwqHVuP_xAJODrs0y0Abw,72
|
|
14
|
-
ai_critic/sessions/store.py,sha256=65m9WXFVFWv4pPzvXV4l8zLHoHWMfCGe6eHh4X-8agY,947
|
|
15
|
-
ai_critic-1.2.0.dist-info/METADATA,sha256=s0XYw_E7ZoVBhF74lyhQsFk_bcyJWY3eo8Yk5E97tZ4,8115
|
|
16
|
-
ai_critic-1.2.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
17
|
-
ai_critic-1.2.0.dist-info/top_level.txt,sha256=TRyZkm1vyLLcFDg_80yeg5cHvPis_oW1Ti170417jkw,10
|
|
18
|
-
ai_critic-1.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|