Open source · scikit-learn native
Predictive donor analytics, done right.
A leakage-safe, pipeline-ready toolkit for nonprofit and academic-medical-center fundraising. Every Tier 1/2 estimator passes scikit-learn's check_estimator.
A ranked call list, scored honestly
import pandas as pd
from sklearn.metrics import roc_auc_score
from sklearn.model_selection import train_test_split
from philanthropy.datasets import generate_synthetic_donor_data
from philanthropy.models import DonorPropensityModel
df = generate_synthetic_donor_data(n_samples=2000, random_state=42)
X = df[["total_gift_amount", "years_active", "event_attendance_count"]].to_numpy()
y = df["is_major_donor"].to_numpy()
# Split BEFORE fitting. Scoring the rows you trained on tells you nothing.
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.25, stratify=y, random_state=42
)
model = DonorPropensityModel(n_estimators=200, random_state=0)
model.fit(X_train, y_train)
scores = model.predict_affinity_score(X_test) # 0-100, not a raw probability
auc = roc_auc_score(y_test, model.predict_proba(X_test)[:, 1])
print(f"held-out ROC-AUC: {auc:.3f}")
print(pd.Series(scores).groupby(y_test).describe()[["count", "mean", "min", "max"]])
0.932held-out ROC-AUC, 500 donors the model never saw
Table view: the printed output and the quartiles behind the chart
What the snippet prints:
The full five-number summary the chart is drawn from:
| Group | n | Min | Q1 | Median | Q3 | Max |
|---|---|---|---|---|---|---|
| Non-major donors | 153 | 0.0 | 1.5 | 8.5 | 38.5 | 100.0 |
| Major donors | 347 | 18.0 | 85.5 | 96.5 | 99.5 | 100.0 |
What is PhilanthroPy?
PhilanthroPy is a production-ready Python library that slots directly into sklearn.pipeline.Pipeline. It covers the full predictive workflow for nonprofit and academic medical center (AMC) fundraising, from raw CRM cleaning and wealth imputation to major-gift propensity scoring, lapse prediction, and planned-giving intent.
Quick start
Get up and running in seconds:
Current release: 0.7.0
pip install philanthropy gives you 0.7.0. These docs are built from
main, which also carries the merged-but-unreleased 1.0.0 work.
See Deprecations for the handful of
differences that affect you today.
Motivation
Predictive fundraising in nonprofits and healthcare foundations is often dominated by proprietary, black-box vendor tools, or brittle, ad-hoc Python scripts that suffer from subtle temporal data leakage across fiscal-year boundaries. Machine-learning code built for the nuances of philanthropic giving was mostly non-existent.
PhilanthroPy exists to change that: a rigorous, open-source, scikit-learn-compatible foundation for donor analytics. It puts advanced fundraising data science within reach of any team, so nonprofits can use their own data to safely and effectively identify their best prospects, without relying entirely on expensive outside vendors.
Key features & capabilities
A comprehensive suite of tools, easy to understand and use:
-
Messy data cleaning
Standardises raw CRM exports (Salesforce NPSP, Raiser's Edge), fixing dates and currency amounts without crashing. Uses
CRMCleaner. -
Fiscal-calendar awareness
Nonprofits run on fiscal years (e.g. July–June). PhilanthroPy understands these boundaries natively, preventing future data from leaking into historical models. Uses
FiscalYearTransformer. -
Smart wealth imputation
Third-party wealth vendors rarely match every record. This estimates missing wealth capacity (like real-estate value) from similar donors using K-nearest neighbours. Uses
WealthScreeningImputerKNN. -
Grateful-patient featurization
For academic medical centers, translates clinical-encounter histories into major-gift signals while decoupling them from explicit patient identifiers (PHI). This reduces compliance risk but is not formal HIPAA de-identification. See Compliance Considerations. Uses
GratefulPatientFeaturizer. -
Propensity & share of wallet
Estimators for capacity utilisation (what share of a donor's modelled wealth is estimated philanthropic capacity, not what share of their giving you receive) and the next best engagement step for a gift officer. Uses
ShareOfWalletScorer.
Getting started
The quickest way to get familiar with PhilanthroPy is to dive into the Tutorials.
Explore the docs
-
Step-by-step, learning-oriented lessons for beginners.
-
Goal-oriented recipes for specific tasks.
-
Understanding-oriented concepts and architecture.
-
Information-oriented API docs.