Skip to main content

Spatial cross-validation in Python

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spacv-0.0.22.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spacv-0.0.22-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file spacv-0.0.22.tar.gz.

File metadata

  • Download URL: spacv-0.0.22.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for spacv-0.0.22.tar.gz
Algorithm Hash digest
SHA256 25e3c581500d0c985d59d7da9889489d07c33b8d12079a55e40b272bada084bc
MD5 195fa35178f218604e35b12fc7ebc531
BLAKE2b-256 6ca71b65570171eea8db991da3c8305d09c70071c83897c1f4fa9cbd32ca34a4

See more details on using hashes here.

File details

Details for the file spacv-0.0.22-py3-none-any.whl.

File metadata

  • Download URL: spacv-0.0.22-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for spacv-0.0.22-py3-none-any.whl
Algorithm Hash digest
SHA256 f9bacbed57bde741e981319387bced036dcadca3f28cf9b22cb7bbaea6d23f66
MD5 ea2774e67165d1c9ca208ff5e521def3
BLAKE2b-256 b1dc71b1af4401d8854434e0c6ecb64a3348c77ac73d9d64192843131156d9f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page