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

Abierto Apto para principiantes
#345 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
72/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
matplotlib, python, scikit-learn

Línea de trabajo

Empieza con la forma de las filas que devuelve explain_donor_scores en philanthropy/inspection/_explain.py y luego revisa cómo philanthropy/visualisation/_plots.py importa matplotlib de forma diferida. Añade plot_score_explanation a philanthropy/visualisation/ para que dibuje un gráfico de barras horizontal con las señales top_n de un donante y devuelva el Axes. Está terminado cuando las pruebas con el backend Agg verifican el número de barras, su orden y sus etiquetas, y el trabajo de CI sin matplotlib sigue pasando.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
11
Forks
23
Merge medio
1 d 11 h
PR fusionados (30 d)
30

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PhilanthroPy-Project/PhilanthroPy

Todos los issues de PhilanthroPy-Project/PhilanthroPy

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.