oraclesai.weights
- class DistanceBandWeightsDefinition(threshold, p=2, alpha=-1.0, binary=True)
Defines a spatial relationship based on a given distance. It uses the distance between two nodes as the weight for the edge connecting them.
- Parameters:
threshold – A distance.
p – float, default=2. Minkowski p-norm, where p=2 refers to the Euclidean distance, and p=1 refers to the Manhattan distance.
alpha – float, default=-1.0. Distance decay, if alpha is positive the weights won’t decline with distance. If binary is True, alpha is ignored.
binary – bool, default=True. If true, the weight \(w_{ij}=1\) if \(d_{ij}<=threshold\); otherwise, \(w_{ij}=0\). If false, \(w_{ij}=d_{ij}^{alpha}\).
- class KNNWeightsDefinition(k: int = 4)
Defines a spatial relationship of K nearest neighbors.
- Parameters:
k – Number of neighbors.
- class KernelBasedWeightsDefinition(bandwidth=None, fixed=True, k=2, function='triangular')
Defines a spatial relationship based on a kernel function, a decay function where closer neighbors have larger values while further neighbors have smaller ones.
- Parameters:
bandwidth – The distance used for the kernel function.
fixed – If True, the same bandwidth is used across all the records. Otherwise, the bandwidth is adaptive across observations.
k – Number of nearest neighbors used to calculate bandwidth. If
fixed=True
, the bandwidth is the maximum distance that guarantees that all observations have at least k neighbors; otherwise, the bandwidth is adaptive, so all observations have exactly k neighbors.function – Name of the kernel function to be used. Available options are: triangular, uniform, quadratic, gaussian.
- class QueenWeightsDefinition
Defines a spatial relationship where two polygons are considered neighbors if they share at least one vertex.
- property index_allowed
Returns true if the spatial weights may be calculated by passing a spatial index of the data.
- class RookWeightsDefinition
Defines a spatial relationship where two polygons are considered neighbors if they share at least one edge.
- property index_allowed
Returns true if the spatial weights may be calculated by passing a spatial index of the data.
- class SpatialWeights(w: W, definition: SpatialWeightsDefinition = None)
- A SpatialWeights instance represents a spatial weights matrix calculated for some data
and a spatial neighboring relationship specified by an instance of
SpatialWeightsDefinition
.
- as_pysal_weights() W
Convert the current SpatialWeight object to its pysal representation
- classmethod create(data, sw_def: SpatialWeightsDefinition)
Computes a SpatialWeights object for the given data.
- Parameters:
data – Either, an instance of
SpatialDataFrame
, geopandas.GeoDataFrame or an Iterable of shapely geometries.sw_def – An instance of
SpatialWeightsDefinition
.
- Returns:
A SpatialWeights object.
- property definition: SpatialWeightsDefinition
The class:oraclesai.weights.SpatialWeightsDefinition that describes the current spatial weights
- classmethod from_pysal_weights(w: W)
Creates a SpatialWeight object from an existing pysal weights object
- class SpatialWeightsDefinition
A concrete implementation of this class defines the criteria used to identify spatial neighbors in a data set so that these neighbors can be used to calculate a spatial weights matrix.
- classmethod from_pysal_weights(w)
Creates a SpatialWeightsDefinition that describes the given pysal weights
- property index_allowed
Returns true if the spatial weights may be calculated by passing a spatial index of the data.