feat(viz): plot one donor's score explanation from `explain_donor_scores`

Aperta Adatta ai principianti
#345 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
matplotlib, python, scikit-learn

Direzione di ricerca

Parti dalla forma delle righe restituite da explain_donor_scores in philanthropy/inspection/_explain.py, poi guarda come philanthropy/visualisation/_plots.py importa matplotlib in modo lazy. Aggiungi plot_score_explanation in philanthropy/visualisation/ in modo che disegni un grafico a barre orizzontali per i segnali top_n di un donatore e restituisca l'Axes. È completato quando i test con il backend Agg verificano numero, ordine ed etichette delle barre e il job CI senza matplotlib continua a passare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement help wanted roadmap
Goal

A gift officer can see why one donor scored high: a small bar chart of the signals that moved that donor's score, built from the existing explain_donor_scores output.

Acceptance criteria
  • philanthropy.visualisation.plot_score_explanation(explanation, row, ax=None) draws a horizontal bar chart from one donor's rows of the explain_donor_scores result and returns the Axes. row matches the result's own row column (the index label of X, or the position for an array); there is no donor_id column. Bars are ordered by rank and signed by contribution.
  • No top_n argument: explain_donor_scores already returns top_k rows per donor (default 3), so the plot draws what it is given and the docstring says to raise top_k for more bars. A row that is not in the frame raises a ValueError naming it.
  • Uses matplotlib only (the existing viz extra), imported lazily inside the function as philanthropy/visualisation/_plots.py does, so importing the package never needs it.
  • Tests use the Agg backend and check bar count, order and labels; the no-matplotlib CI job still passes.
  • Exported from philanthropy.visualisation and its __all__, with a tier row in docs/reference/index.md (a test fails without one).
  • One image in the "Explain a donor's score" how-to.
  • CHANGELOG entry.
Scope

Plotting only. No SHAP dependency: this rescopes #5 now that explain_donor_scores (#326) ships per-donor explanations with the existing stack.

Where to start
  • philanthropy/inspection/_explain.py (the input shape)
  • philanthropy/visualisation/ for the existing plot helpers' conventions
  • docs/how-to/explain_a_donor_score.md
Dependencies
  • Supersedes the plotting half of #5

Phase order is a release plan, not a rule against picking up independent work early. Comment on this issue before you start so two people don't build the same thing.

Lingua principale
Python
Stelle
11
Fork
23
Merge medio
1g 11h
PR unite (30g)
30

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PhilanthroPy-Project/PhilanthroPy

Tutte le issue di PhilanthroPy-Project/PhilanthroPy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.