@@ -81,27 +81,49 @@ uv run python advanced_training.py
81
81
- Training parameter tuning
82
82
- Model performance comparison
83
83
84
- ### 5. [ MLflow Integration] ( mlflow_integration.py )
85
- Demonstrates MLflow integration for experiment tracking and model management:
86
- - Training and logging models to MLflow
87
- - Experiment tracking with metrics and parameters
88
- - Model versioning and registry
89
- - Loading models from MLflow for inference
90
- - Model artifact management
84
+ ### 5. [ Categorical Comparison] ( categorical_comparison.py )
85
+ Compares model performance with and without categorical features:
86
+ - Loading real-world data (Sirene dataset)
87
+ - Feature engineering and preprocessing
88
+ - Model comparison with statistical analysis
89
+ - Performance evaluation and visualization
91
90
92
91
** Run the example:**
93
92
``` bash
94
93
cd examples
95
- pip install mlflow # Install MLflow first
96
- uv run python mlflow_integration.py
94
+ uv run python categorical_comparison.py
97
95
```
98
96
99
97
** What you'll learn:**
100
- - MLflow experiment tracking setup
101
- - Model logging and versioning
102
- - Loading models for inference
103
- - Model registry management
104
- - Reproducible ML workflows
98
+ - Real-world data handling
99
+ - Feature impact analysis
100
+ - Statistical model comparison
101
+ - Data preprocessing techniques
102
+
103
+ ### 6. [ Simple Explainability] ( simple_explainability_example.py )
104
+ Demonstrates model explainability with ASCII histogram visualizations:
105
+ - Training a FastText classifier with enhanced data
106
+ - Word-level contribution analysis
107
+ - ASCII histogram visualization in terminal
108
+ - Interactive mode for custom text analysis
109
+ - Real-time prediction explanations
110
+
111
+ ** Run the example:**
112
+ ``` bash
113
+ cd examples
114
+ # Regular mode - analyze predefined examples
115
+ uv run python simple_explainability_example.py
116
+
117
+ # Interactive mode - analyze your own text
118
+ uv run python simple_explainability_example.py --interactive
119
+ ```
120
+
121
+ ** What you'll learn:**
122
+ - Model explainability and interpretation
123
+ - Word importance analysis
124
+ - Interactive prediction tools
125
+ - ASCII-based data visualization
126
+ - Real-time model analysis
105
127
106
128
## π Quick Start
107
129
@@ -191,6 +213,118 @@ Class distribution: Negative=5, Neutral=5, Positive=5
191
213
Final Accuracy: 3/6 = 0.500
192
214
```
193
215
216
+ ### Simple Explainability
217
+ ```
218
+ π Simple Explainability Example
219
+
220
+ π Testing explainability on 5 examples:
221
+ ============================================================
222
+
223
+ π Example 1:
224
+ Text: 'This product is amazing!'
225
+ Prediction: Positive
226
+
227
+ π Word Contribution Histogram:
228
+ --------------------------------------------------
229
+ This | ββββββββββββββββββββββββββββββ 0.3549
230
+ product | βββββββββββββ 0.1651
231
+ is | ββββββββββββββββββββββββ 0.2844
232
+ amazing! | ββββββββββββββββ 0.1956
233
+ --------------------------------------------------
234
+ β
Analysis completed for example 1
235
+
236
+ π Example 2:
237
+ Text: 'Poor quality and terrible service'
238
+ Prediction: Negative
239
+ β οΈ Explainability failed:
240
+ β
Analysis completed for example 2
241
+
242
+ π Example 3:
243
+ Text: 'Great value for money'
244
+ Prediction: Positive
245
+
246
+ π Word Contribution Histogram:
247
+ --------------------------------------------------
248
+ Great | ββββββββββββββββββββββββββββββ 0.3287
249
+ value | ββββββββββββββββββββ 0.2220
250
+ for | ββββββββββββββββββββββββββ 0.2929
251
+ money | ββββββββββββββ 0.1564
252
+ --------------------------------------------------
253
+ β
Analysis completed for example 3
254
+
255
+ π Example 4:
256
+ Text: 'Completely disappointing and awful experience'
257
+ Prediction: Negative
258
+
259
+ π Word Contribution Histogram:
260
+ --------------------------------------------------
261
+ Completely | ββββββββββ 0.1673
262
+ disappointing | ββββββββββββββββββββββββββββββ 0.4676
263
+ and | βββββ 0.0910
264
+ awful | βββββββ 0.1225
265
+ experience | βββββββββ 0.1516
266
+ --------------------------------------------------
267
+ β
Analysis completed for example 4
268
+
269
+ π Example 5:
270
+ Text: 'Love this excellent design'
271
+ Prediction: Positive
272
+
273
+ π Word Contribution Histogram:
274
+ --------------------------------------------------
275
+ Love | ββββββββββββββββββ 0.2330
276
+ this | ββββββββββββββββββββ 0.2525
277
+ excellent | ββββββββββββββββββββββββββββββ 0.3698
278
+ design | βββββββββββ 0.1447
279
+ --------------------------------------------------
280
+ β
Analysis completed for example 5
281
+
282
+ π Explainability analysis completed for 5 examples!
283
+
284
+ π‘ Tip: Use --interactive flag to enter interactive mode for custom text analysis!
285
+ Example: uv run python examples/simple_explainability_example.py --interactive
286
+ ```
287
+
288
+ ### Interactive Explainability Mode
289
+ ```
290
+ ============================================================
291
+ π― Interactive Explainability Mode
292
+ ============================================================
293
+ Enter your own text to see predictions and explanations!
294
+ Type 'quit' or 'exit' to end the session.
295
+
296
+ π¬ Enter text: Amazing product quality!
297
+
298
+ π Analyzing: 'Amazing product quality!'
299
+ π― Prediction: Positive
300
+
301
+ π Word Contribution Histogram:
302
+ --------------------------------------------------
303
+ Amazing | ββββββββββββββββββββββββββββββ 0.5429
304
+ product | ββββββββββββββ 0.2685
305
+ quality! | ββββββββββ 0.1886
306
+ --------------------------------------------------
307
+ π‘ Most influential word: 'Amazing' (score: 0.5429)
308
+
309
+ --------------------------------------------------
310
+ π¬ Enter text: Terrible customer support
311
+
312
+ π Analyzing: 'Terrible customer support'
313
+ π― Prediction: Negative
314
+
315
+ π Word Contribution Histogram:
316
+ --------------------------------------------------
317
+ Terrible | ββββββββββββββββββββββββββββββ 0.5238
318
+ customer | βββββββββββ 0.1988
319
+ support | βββββββββββββββ 0.2774
320
+ --------------------------------------------------
321
+ π‘ Most influential word: 'Terrible' (score: 0.5238)
322
+
323
+ --------------------------------------------------
324
+ π¬ Enter text: quit
325
+ π Thanks for using the explainability tool!
326
+ ```
327
+
194
328
## π οΈ Customizing Examples
195
329
196
330
### Modify Data
0 commit comments