Utils Reference
Model persistence (save_model, load_model) and the synthetic dataset helper
used throughout the tutorials (make_donor_dataset).
philanthropy.utils
Generic helpers: model persistence and deprecated aliases.
save_model(model, path, *, features=None, target=None)
Persist model to path as a PhilanthroPy bundle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
fitted estimator
|
Any PhilanthroPy or scikit-learn estimator. |
required |
path
|
str or Path
|
Output path ( |
required |
features
|
list of str
|
Ordered feature-column names the model was trained on. |
None
|
target
|
str
|
Name of the target column. |
None
|
Returns:
| Type | Description |
|---|---|
path
|
The |
Source code in philanthropy/utils/_persistence.py
load_model(path)
Load a bundle written by :func:save_model.
Warns (does not raise) when the stored PhilanthroPy or scikit-learn version differs from the running environment, since an estimator un-pickled under a different scikit-learn can silently misbehave.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Bundle path. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The bundle: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file is not a PhilanthroPy bundle. |
Source code in philanthropy/utils/_persistence.py
make_donor_dataset(*args, **kwargs)
Deprecated alias for :func:philanthropy.datasets.make_donor_dataset.