Skip to main content

Open-source spatial statistics library for geo-financial analysis

Project description

libgeofin

Open-source spatial statistics library for geo-financial analysis · MIT License

libgeofin is the open-source core algorithm library of the GeoFinance Insights project. Financial institutions and academic researchers are free to audit, reproduce, and use the spatial statistics formulae it provides.

Installation

pip install libgeofin
# or install from source
pip install -e .

Quick Start

import numpy as np
from libgeofin import build_weight_matrix, compute_moran_i, lisa_quadrant

# 1. Build a spatial weight matrix
points = [(31.22, 121.47), (31.23, 121.48), (31.21, 121.46)]
W = build_weight_matrix(points, bandwidth_km=2.0)

# 2. Compute Moran's I
values = np.array([10.0, 12.0, 8.0])
moran_i, z_score, p_value = compute_moran_i(values, W)
print(f"Moran's I = {moran_i:.4f}, p = {p_value:.4f}")

# 3. LISA quadrant classification
spatial_lag = float(W[0] @ values)
quadrant = lisa_quadrant(
    local_val=values[0],
    spatial_lag=spatial_lag,
    global_mean=values.mean(),
    p_value=p_value,
)
print(f"LISA quadrant: {quadrant}")  # HH / LL / LH / HL / NS

Modules

Module Function Description
libgeofin.weights haversine_km Haversine great-circle distance (km)
libgeofin.weights gaussian_kernel Gaussian kernel function
libgeofin.weights build_weight_matrix Row-standardised spatial weight matrix
libgeofin.autocorrelation compute_moran_i Global Moran's I + Z-test
libgeofin.autocorrelation lisa_quadrant LISA quadrant classification
libgeofin.normalize standardize Z-score standardisation
libgeofin.normalize coords_to_distance_matrix Lat/lng coordinates → pairwise distance matrix

Formula Reference

Moran's I:

$$I = \frac{n}{S_0} \cdot \frac{\mathbf{y}^\top W \mathbf{y}}{\mathbf{y}^\top \mathbf{y}}$$

Spatially adjusted rent (implemented in the closed-source GeoFinance Pro layer):

$$R_{adj} = R_{base} \cdot (1 + \rho \cdot Wy)$$

Scope of Open-Source Release

This library contains only the pure mathematical / statistical components. The following belong to the closed-source GeoFinance Pro commercial platform and are not included here:

  • Moran's I → rent-growth-rate conversion engine
  • Dynamic IRR / NPV financial calculator
  • POI data crawler and API integrations
  • Automated investment research report generator

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

libgeofin-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

libgeofin-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file libgeofin-0.1.0.tar.gz.

File metadata

  • Download URL: libgeofin-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for libgeofin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 abe3bce91b82910fedf5c8549608ac5644300675668a99cf4734418d02e875bb
MD5 75f602b5c9cb83ae17bdb8b96946e623
BLAKE2b-256 5b00a23b1e8cc50c15c96d3dc1c85797e1ffb4a7a6be0a85ac3b95f937103d34

See more details on using hashes here.

File details

Details for the file libgeofin-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: libgeofin-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for libgeofin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0ff427a874e7182e79cb1425cc09a1bfbbfd13c4043e7929317a3b9fb9c8dfc
MD5 7a1a9bdebca6a9beba61ebae1d8e8636
BLAKE2b-256 37b064bfb134a2397dc67329e54accde3f09f2f4b7bd8fc18ffc1089618186a2

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