shap.datasets.communitiesandcrime

shap.datasets.communitiesandcrime(n_points: int | None = None) tuple[DataFrame, ndarray]

Predict the total number of violent crimes per 100K population.

This dataset is from the classic UCI Machine Learning repository: https://archive.ics.uci.edu/ml/datasets/Communities+and+Crime+Unnormalized

Used in predictive regression tasks.

Parameters:
n_pointsint, optional

Number of data points to sample. If provided, randomly samples the specified number of points.

Returns:
Xpd.DataFrame

The feature data.

ynp.ndarray

The target variable.

Examples

To get the processed data and target labels:

data, target = shap.datasets.communitiesandcrime()