ai-critic 0.2.5__tar.gz → 1.0.0__tar.gz

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.
Files changed (26) hide show
  1. ai_critic-1.0.0/PKG-INFO +257 -0
  2. ai_critic-1.0.0/README.md +247 -0
  3. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic/critic.py +71 -45
  4. ai_critic-1.0.0/ai_critic/evaluators/scoring.py +39 -0
  5. ai_critic-1.0.0/ai_critic/sessions/__init__.py +3 -0
  6. ai_critic-1.0.0/ai_critic/sessions/store.py +33 -0
  7. ai_critic-1.0.0/ai_critic.egg-info/PKG-INFO +257 -0
  8. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic.egg-info/SOURCES.txt +3 -0
  9. {ai_critic-0.2.5 → ai_critic-1.0.0}/pyproject.toml +1 -1
  10. ai_critic-0.2.5/PKG-INFO +0 -200
  11. ai_critic-0.2.5/README.md +0 -190
  12. ai_critic-0.2.5/ai_critic.egg-info/PKG-INFO +0 -200
  13. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic/__init__.py +0 -0
  14. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic/evaluators/__init__.py +0 -0
  15. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic/evaluators/config.py +0 -0
  16. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic/evaluators/data.py +0 -0
  17. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic/evaluators/performance.py +0 -0
  18. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic/evaluators/robustness.py +0 -0
  19. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic/evaluators/summary.py +0 -0
  20. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic/evaluators/validation.py +0 -0
  21. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic.egg-info/dependency_links.txt +0 -0
  22. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic.egg-info/requires.txt +0 -0
  23. {ai_critic-0.2.5 → ai_critic-1.0.0}/ai_critic.egg-info/top_level.txt +0 -0
  24. {ai_critic-0.2.5 → ai_critic-1.0.0}/setup.cfg +0 -0
  25. {ai_critic-0.2.5 → ai_critic-1.0.0}/test/test_in_ia.py +0 -0
  26. {ai_critic-0.2.5 → ai_critic-1.0.0}/test/test_model.py +0 -0
@@ -0,0 +1,257 @@
1
+ Metadata-Version: 2.4
2
+ Name: ai-critic
3
+ Version: 1.0.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–compatible Machine Learning 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
+ ### Full Technical & Visual Analysis
95
+
96
+ To access **all internal diagnostics**, including plots and recommendations, use `view="all"`.
97
+
98
+ ```python
99
+ full_report = critic.evaluate(view="all", plot=True)
100
+
101
+ technical_summary = full_report["technical"]
102
+
103
+ print("\n--- Key Risks Detected ---")
104
+ for i, risk in enumerate(technical_summary["key_risks"], start=1):
105
+ print(f"{i}. {risk}")
106
+
107
+ print("\n--- Recommendations ---")
108
+ for rec in technical_summary["recommendations"]:
109
+ print(f"- {rec}")
110
+ ```
111
+
112
+ Generated plots may include:
113
+
114
+ * Feature correlation heatmaps
115
+ * Learning curves
116
+ * Robustness degradation charts
117
+
118
+ ---
119
+
120
+ ### Robustness Test (Noise Injection)
121
+
122
+ A model that collapses under small perturbations is **not production-safe**.
123
+
124
+ ```python
125
+ robustness = full_report["details"]["robustness"]
126
+
127
+ print("\n--- Robustness Analysis ---")
128
+ print(f"Original CV Score: {robustness['cv_score_original']:.4f}")
129
+ print(f"Noisy CV Score: {robustness['cv_score_noisy']:.4f}")
130
+ print(f"Performance Drop: {robustness['performance_drop']:.4f}")
131
+ print(f"Verdict: {robustness['verdict']}")
132
+ ```
133
+
134
+ **Possible Verdicts:**
135
+
136
+ * `stable` → acceptable degradation
137
+ * `fragile` → high sensitivity to noise
138
+ * `misleading` → performance likely inflated by leakage
139
+
140
+ ---
141
+
142
+ ## ⚙️ Integration and Governance (The Advanced)
143
+
144
+ This section targets **MLOps engineers**, **architects**, and teams operating automated pipelines.
145
+
146
+ ---
147
+
148
+ ### The Deployment Gate (`deploy_decision`)
149
+
150
+ The `deploy_decision()` method aggregates *all detected risks* and produces a final gate decision.
151
+
152
+ ```python
153
+ decision = critic.deploy_decision()
154
+
155
+ if decision["deploy"]:
156
+ print("✅ Deployment Approved")
157
+ else:
158
+ print("❌ Deployment Blocked")
159
+
160
+ print(f"Risk Level: {decision['risk_level']}")
161
+ print(f"Confidence Score: {decision['confidence']:.2f}")
162
+
163
+ print("\nBlocking Issues:")
164
+ for issue in decision["blocking_issues"]:
165
+ print(f"- {issue}")
166
+ ```
167
+
168
+ **Conceptual model:**
169
+
170
+ * **Hard Blockers** → deployment denied
171
+ * **Soft Blockers** → deployment discouraged
172
+ * **Confidence Score (0–1)** → heuristic trust level
173
+
174
+ ---
175
+
176
+ ### Modes & Views (API Design)
177
+
178
+ The `evaluate()` method supports **multiple modes** via the `view` parameter:
179
+
180
+ | View | Description |
181
+ | ------------- | ---------------------------------- |
182
+ | `"executive"` | High-level verdict (non-technical) |
183
+ | `"technical"` | Risks & recommendations |
184
+ | `"details"` | Raw evaluator outputs |
185
+ | `"all"` | Complete payload |
186
+
187
+ Example:
188
+
189
+ ```python
190
+ critic.evaluate(view="technical")
191
+ critic.evaluate(view=["executive", "performance"])
192
+ ```
193
+
194
+ ---
195
+
196
+ ### Session Tracking & Model Comparison (New in 1.0.0)
197
+
198
+ You can persist evaluations and compare model versions over time.
199
+
200
+ ```python
201
+ critic_v1 = AICritic(model, X, y, session="v1")
202
+ critic_v1.evaluate()
203
+
204
+ critic_v2 = AICritic(model, X, y, session="v2")
205
+ critic_v2.evaluate()
206
+
207
+ comparison = critic_v2.compare_with("v1")
208
+ print(comparison["score_diff"])
209
+ ```
210
+
211
+ This enables:
212
+
213
+ * Regression tracking
214
+ * Risk drift detection
215
+ * Governance & audit trails
216
+
217
+ ---
218
+
219
+ ### Best Practices & Use Cases
220
+
221
+ | Scenario | Recommended Usage |
222
+ | ----------------------- | -------------------------------------- |
223
+ | **CI/CD** | Block merges using `deploy_decision()` |
224
+ | **Model Tuning** | Use technical view for guidance |
225
+ | **Governance** | Persist session outputs |
226
+ | **Stakeholder Reports** | Share executive summaries |
227
+
228
+ ---
229
+ ## 🔒 API Stability
230
+
231
+ Starting from version **1.0.0**, the public API of **ai-critic** follows semantic versioning.
232
+ Breaking changes will only occur in major releases.
233
+
234
+ ## 📄 License
235
+
236
+ Distributed under the **MIT License**.
237
+
238
+ ---
239
+
240
+ ## 🧠 Final Note
241
+
242
+ > **ai-critic is not a benchmarking tool.**
243
+ > It is a *decision-making system*.
244
+
245
+ A failed audit does **not** mean the model is bad — it means the model **is not ready to be trusted**.
246
+
247
+ The purpose of **ai-critic** is to introduce *structured skepticism* into machine learning workflows — exactly where it belongs.
248
+
249
+ ---
250
+
251
+ Se quiser, próximo passo posso:
252
+
253
+ * gerar o **CHANGELOG.md oficial do 1.0.0**
254
+ * revisar esse README como um **reviewer externo**
255
+ * escrever o **post de lançamento** (GitHub / PyPI / Reddit)
256
+
257
+ Esse README já está em **nível profissional real**.
@@ -0,0 +1,247 @@
1
+ # ai-critic 🧠: The Quality Gate for Machine Learning Models
2
+
3
+ **ai-critic** is a specialized **decision-making** tool designed to audit the reliability and readiness for deployment of scikit-learn–compatible Machine Learning models.
4
+
5
+ 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**.
6
+
7
+ > **ai-critic does not ask “How good is this model?”**
8
+ > It asks **“Can this model be trusted?”**
9
+
10
+ ---
11
+
12
+ ## 🚀 Getting Started (The Basics)
13
+
14
+ This section is ideal for beginners who need a **fast and reliable verdict** on a trained model.
15
+
16
+ ### Installation
17
+
18
+ Install directly from PyPI:
19
+
20
+ ```bash
21
+ pip install ai-critic
22
+ ```
23
+
24
+ ---
25
+
26
+ ### The Quick Verdict
27
+
28
+ With just a few lines of code, you obtain an **executive-level assessment** and a **deployment recommendation**.
29
+
30
+ ```python
31
+ from ai_critic import AICritic
32
+ from sklearn.ensemble import RandomForestClassifier
33
+ from sklearn.datasets import make_classification
34
+
35
+ # 1. Prepare data and model
36
+ X, y = make_classification(n_samples=1000, n_features=20, random_state=42)
37
+ model = RandomForestClassifier(max_depth=5, random_state=42)
38
+
39
+ # 2. Initialize the Critic
40
+ critic = AICritic(model, X, y)
41
+
42
+ # 3. Run the audit (executive mode)
43
+ report = critic.evaluate(view="executive")
44
+
45
+ print(f"Verdict: {report['verdict']}")
46
+ print(f"Risk Level: {report['risk_level']}")
47
+ print(f"Main Reason: {report['main_reason']}")
48
+ ```
49
+
50
+ **Expected Output (example):**
51
+
52
+ ```text
53
+ Verdict: ⚠️ Risky
54
+ Risk Level: medium
55
+ Main Reason: Structural or robustness-related risks detected.
56
+ ```
57
+
58
+ This output is intentionally **conservative**.
59
+ If **ai-critic** recommends deployment, it means meaningful risks were *not* detected.
60
+
61
+ ---
62
+
63
+ ## 💡 Understanding the Critique (The Intermediary)
64
+
65
+ For data scientists who want to understand **why** the model received a given verdict and **how to improve it**.
66
+
67
+ ---
68
+
69
+ ### The Four Pillars of the Audit
70
+
71
+ **ai-critic** evaluates models across four independent risk dimensions:
72
+
73
+ | Pillar | Main Risk Detected | Internal Module |
74
+ | ---------------------- | -------------------------------------- | ------------------------ |
75
+ | 📊 **Data Integrity** | Target Leakage & Correlation Artifacts | `evaluators.data` |
76
+ | 🧠 **Model Structure** | Over-complexity & Misconfiguration | `evaluators.config` |
77
+ | 📈 **Performance** | Suspicious CV or Learning Curves | `evaluators.performance` |
78
+ | 🧪 **Robustness** | Sensitivity to Noise | `evaluators.robustness` |
79
+
80
+ Each pillar contributes signals used later in the **deployment gate**.
81
+
82
+ ---
83
+
84
+ ### Full Technical & Visual Analysis
85
+
86
+ To access **all internal diagnostics**, including plots and recommendations, use `view="all"`.
87
+
88
+ ```python
89
+ full_report = critic.evaluate(view="all", plot=True)
90
+
91
+ technical_summary = full_report["technical"]
92
+
93
+ print("\n--- Key Risks Detected ---")
94
+ for i, risk in enumerate(technical_summary["key_risks"], start=1):
95
+ print(f"{i}. {risk}")
96
+
97
+ print("\n--- Recommendations ---")
98
+ for rec in technical_summary["recommendations"]:
99
+ print(f"- {rec}")
100
+ ```
101
+
102
+ Generated plots may include:
103
+
104
+ * Feature correlation heatmaps
105
+ * Learning curves
106
+ * Robustness degradation charts
107
+
108
+ ---
109
+
110
+ ### Robustness Test (Noise Injection)
111
+
112
+ A model that collapses under small perturbations is **not production-safe**.
113
+
114
+ ```python
115
+ robustness = full_report["details"]["robustness"]
116
+
117
+ print("\n--- Robustness Analysis ---")
118
+ print(f"Original CV Score: {robustness['cv_score_original']:.4f}")
119
+ print(f"Noisy CV Score: {robustness['cv_score_noisy']:.4f}")
120
+ print(f"Performance Drop: {robustness['performance_drop']:.4f}")
121
+ print(f"Verdict: {robustness['verdict']}")
122
+ ```
123
+
124
+ **Possible Verdicts:**
125
+
126
+ * `stable` → acceptable degradation
127
+ * `fragile` → high sensitivity to noise
128
+ * `misleading` → performance likely inflated by leakage
129
+
130
+ ---
131
+
132
+ ## ⚙️ Integration and Governance (The Advanced)
133
+
134
+ This section targets **MLOps engineers**, **architects**, and teams operating automated pipelines.
135
+
136
+ ---
137
+
138
+ ### The Deployment Gate (`deploy_decision`)
139
+
140
+ The `deploy_decision()` method aggregates *all detected risks* and produces a final gate decision.
141
+
142
+ ```python
143
+ decision = critic.deploy_decision()
144
+
145
+ if decision["deploy"]:
146
+ print("✅ Deployment Approved")
147
+ else:
148
+ print("❌ Deployment Blocked")
149
+
150
+ print(f"Risk Level: {decision['risk_level']}")
151
+ print(f"Confidence Score: {decision['confidence']:.2f}")
152
+
153
+ print("\nBlocking Issues:")
154
+ for issue in decision["blocking_issues"]:
155
+ print(f"- {issue}")
156
+ ```
157
+
158
+ **Conceptual model:**
159
+
160
+ * **Hard Blockers** → deployment denied
161
+ * **Soft Blockers** → deployment discouraged
162
+ * **Confidence Score (0–1)** → heuristic trust level
163
+
164
+ ---
165
+
166
+ ### Modes & Views (API Design)
167
+
168
+ The `evaluate()` method supports **multiple modes** via the `view` parameter:
169
+
170
+ | View | Description |
171
+ | ------------- | ---------------------------------- |
172
+ | `"executive"` | High-level verdict (non-technical) |
173
+ | `"technical"` | Risks & recommendations |
174
+ | `"details"` | Raw evaluator outputs |
175
+ | `"all"` | Complete payload |
176
+
177
+ Example:
178
+
179
+ ```python
180
+ critic.evaluate(view="technical")
181
+ critic.evaluate(view=["executive", "performance"])
182
+ ```
183
+
184
+ ---
185
+
186
+ ### Session Tracking & Model Comparison (New in 1.0.0)
187
+
188
+ You can persist evaluations and compare model versions over time.
189
+
190
+ ```python
191
+ critic_v1 = AICritic(model, X, y, session="v1")
192
+ critic_v1.evaluate()
193
+
194
+ critic_v2 = AICritic(model, X, y, session="v2")
195
+ critic_v2.evaluate()
196
+
197
+ comparison = critic_v2.compare_with("v1")
198
+ print(comparison["score_diff"])
199
+ ```
200
+
201
+ This enables:
202
+
203
+ * Regression tracking
204
+ * Risk drift detection
205
+ * Governance & audit trails
206
+
207
+ ---
208
+
209
+ ### Best Practices & Use Cases
210
+
211
+ | Scenario | Recommended Usage |
212
+ | ----------------------- | -------------------------------------- |
213
+ | **CI/CD** | Block merges using `deploy_decision()` |
214
+ | **Model Tuning** | Use technical view for guidance |
215
+ | **Governance** | Persist session outputs |
216
+ | **Stakeholder Reports** | Share executive summaries |
217
+
218
+ ---
219
+ ## 🔒 API Stability
220
+
221
+ Starting from version **1.0.0**, the public API of **ai-critic** follows semantic versioning.
222
+ Breaking changes will only occur in major releases.
223
+
224
+ ## 📄 License
225
+
226
+ Distributed under the **MIT License**.
227
+
228
+ ---
229
+
230
+ ## 🧠 Final Note
231
+
232
+ > **ai-critic is not a benchmarking tool.**
233
+ > It is a *decision-making system*.
234
+
235
+ A failed audit does **not** mean the model is bad — it means the model **is not ready to be trusted**.
236
+
237
+ The purpose of **ai-critic** is to introduce *structured skepticism* into machine learning workflows — exactly where it belongs.
238
+
239
+ ---
240
+
241
+ Se quiser, próximo passo posso:
242
+
243
+ * gerar o **CHANGELOG.md oficial do 1.0.0**
244
+ * revisar esse README como um **reviewer externo**
245
+ * escrever o **post de lançamento** (GitHub / PyPI / Reddit)
246
+
247
+ Esse README já está em **nível profissional real**.