Skip to main content

spacv: spatial cross-validation in Python

spacv is a small Python 3 (3.6 and above) package for cross-validation of models that assess generalization performance to datasets with spatial dependence. spacv provides a familiar sklearn-like API to expose a suite of tools useful for points-based spatial prediction tasks. See the notebook spacv_guide.ipynb for usage.

Dependencies

  • numpy
  • matplotlib
  • pandas
  • geopandas
  • shapely
  • scikit-learn
  • scipy

Installation and usage

To install use pip:

$ pip install spacv

Then build quick spatial cross-validation workflows with sklearn as:

import spacv
import geopandas as gpd
from sklearn.model_selection import cross_val_score
from sklearn.svm import SVC

df = gpd.read_file('data/baltim.geojson')

XYs = df['geometry']
X = df[['NROOM', 'BMENT', 'NBATH', 'PRICE', 'LOTSZ', 'SQFT']]
y = df['PATIO']

# Build fold indices as a generator
skcv = spacv.SKCV(n_splits=4, buffer_radius=10).split(XYs)

svc = SVC()

cross_val_score(svc,       # Model 
                X,         # Features
                y,         # Labels
                cv = skcv) # Fold indices

Metadata

Release files for spacv 0.0.22

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spacv 0.0.22
File Size Uploaded
spacv-0.0.22.tar.gz 13.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spacv 0.0.22
File Interpreter ABI Platform
spacv-0.0.22-py3-none-any.whl Python 3 none any Details

Total release size: 28.9 kB

Release files / spacv-0.0.22.tar.gz

Download URL spacv-0.0.22.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
25e3c581500d0c985d59d7da9889489d07c33b8d12079a55e40b272bada084bc
BLAKE2b-256 checksum
How to use checksums
6ca71b65570171eea8db991da3c8305d09c70071c83897c1f4fa9cbd32ca34a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191201 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.3

Release files / spacv-0.0.22-py3-none-any.whl

Download URL spacv-0.0.22-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9bacbed57bde741e981319387bced036dcadca3f28cf9b22cb7bbaea6d23f66
BLAKE2b-256 checksum
How to use checksums
b1dc71b1af4401d8854434e0c6ecb64a3348c77ac73d9d64192843131156d9f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191201 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.0.22 This release

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page