oraclesai.analysis
- class LocalMoranITest(data, column_name, weights=None, weights_definition=None, **kwargs)
An implementation of the Local Moran’s I spatial autocorrelation test.
- COL_I (‘I’)
Name of the column containing the Moran I value in the resulting output data returned by
get_output_data()
.- COL_P_VALUE (‘P_VALUE’)
Name of the column containing the p values in the resulting output data returned by
get_output_data()
- COL_Z_VALUE (‘Z_VALUE’)
Name of the column containing the z values in the resulting output data returned by
get_output_data()
- COL_Q (‘QUADRANT’)
Name of the column containing the quadrant information in the resulting output data returned by
get_output_data()
- classmethod create(data, weights_or_def, column_name=None)
Create an instance of LocalMoranITest. The test is applied on a column from the given data using the specified spatial weights.
- Parameters:
data – Either, an instance of
SpatialDataFrame
, geopandas.GeoDataFrame or an Iterable of float values.weights_or_def – A
SpatialWeightsDefinition
instance orSpatialWeights
object.column_name – Name of the column from the data parameter. If None, data must be an Iterable of float values or a dataframe containing only one data column (it may contain a geometry and index columns.)
- Returns:
A LocalMoranITest object.
- get_coldspot(max_p_value=0.05)
Returns a subset of the input data containing samples which lay into the cold spot.
- Parameters:
max_p_value – Maximum p value for a sample to be considered to be in the cold spot.
- Returns:
A subset of the data used to run the analysis. The type is the same than the input data.
- get_hotspot(max_p_value=0.05)
Returns a subset of the input data containing samples which lay into the hot spot.
- Parameters:
max_p_value – Maximum p value for a sample to be considered to be in the hot spot.
- Returns:
A subset of the data used to run the analysis. The type is the same than the input data.
- get_outliers(max_p_value=0.05)
Returns a subset of the input data containing samples which are considered outliers.
- Parameters:
max_p_value – Maximum p value for a sample to be considered to be in the outliers.
- Returns:
A subset of the data used to run the analysis. The type is the same than the input data.
- get_output_data()
Returns the input data plus local spatial autocorrelation test columns
COL_I
,COL_P_VALUE
,COL_Z_VALUE
andCOL_Q
.- Returns:
A data set of the same type as the data used to run the analysis.
- property i_list
List of Moran’s I values
- property p_values
List of p values
- property quadrants
List of int values representing quadrants. Different quadrant values are defined at
Quadrant
- property z_values
List of z values
- class MoranITest(data, weights=None, weights_definition=None, column_name=None, **kwargs)
An implementation of the Moran I spatial autocorrelation test.
- classmethod create(data, weights_or_def, column_name=None)
Create an instance of MoranITest. The returned instance contains the results of the global Moran’s I spatial autocorrelation test applied on the specified column from the given data.
- Parameters:
data – Either, an instance of
SpatialDataFrame
, geopandas.GeoDataFrame or an Iterable of float values.weightsor_or_def – Either, a spatial weights definition or computed spatial weights as instances of SpatialWeights or pysal Weights.
column_name – Name of the column from the data parameter. If None, data must be an Iterable of float values or a dataframe containing only one data column (it may contain a geometry and index columns.)
- Returns:
A MoranITest object.
- property spatial_weights
Spatial weights object used to compute Moran I.
- property z_value
Z Value.
- class Quadrant(**keyargs)
Defines values for representing quadrants in a plane which are associated with different types of spatial autocorrelations.
Attributes:
- HOTSPOT (1)
Quadrant for high-high values.
- DOUGHNUT (2)
Quadrant for high-low values.
- COLDSPOT (3)
Quadrant for low-low values.
- DIAMOND (4)
Quadrant for low-high values.
- spatial_colocation_analysis(feature_data, spatial_weights_definition, interest_category=None, neighbor_category=None, neighbor_feature_data=None, is_time_window_analysis=False, interest_time_window=None, neighbor_time_widow=None, n_permutations=None)
Spatial colocation measures and analyze relationships between point features of different classes from the same spatial layer and, or from different spatial layers. Colocation Analysis is a tool that measures proximity patterns between two categories of point features, A and B, using the Local Colocation Quotient (LCLQ) statistic. For each feature of the Category of Interest (category A), it calculates its LCLQ score. If the proportion of points of category B within its neighborhood is more than the global proportion of B points, the LCLQ value will be high. • If there are more A points or more points from categories other than B within its neighborhood, the LCLQ score will be small.
- Parameters:
feature_data – GeoDataFrame of SpatialDataFrame. The data that will be used for the colocation analysis
spatial_weights_definition – SpatialWeightsDefinition. Specifies how the distance between neighbors is calculated
interest_category – tuple. default=None. Two values indicating the field and value of the category of interest
neighbor_category – tuple. default=None. Two values indicating the field and value of the neighboring category
neighbor_feature_data – GeoDataFrame of SpatialDataFrame. default=None. If present, the neighboring observations come from here
is_time_window_analysis – boolean, default=False. Indicates if time window_analysis will be used
interest_time_window – tuple, default=None. Requires is_time_window_analysis to be true. It contains three values indicating the field, start time, end time for interest category
neighbor_time_widow – tuple, default=None. Requires is_time_window_analysis to be true. It contains three values indicating the field, start time, end time for neighboring category
n_permutations – int, default=None. The number of permutations used to calculate the significance level of the colocation quotient scores. If None, the significance level is None