sedona.spark.stats.outlier_detection package
Submodules
sedona.spark.stats.outlier_detection.local_outlier_factor module
Functions related to calculating the local outlier factor of a dataset.
- sedona.spark.stats.outlier_detection.local_outlier_factor.local_outlier_factor(dataframe: DataFrame, k: int = 20, geometry: str | None = None, handle_ties: bool = False, use_spheroid=False, result_column_name: str = 'lof')[source]
Annotates a dataframe with a column containing the local outlier factor for each data record.
The dataframe should contain at least one GeometryType column. Rows must be unique. If one geometry column is present it will be used automatically. If two are present, the one named ‘geometry’ will be used. If more than one are present and neither is named ‘geometry’, the column name must be provided.
- Parameters:
dataframe – apache sedona idDataframe containing the point geometries
k – number of nearest neighbors that will be considered for the LOF calculation
geometry – name of the geometry column
handle_ties – whether to handle ties in the k-distance calculation. Default is false
use_spheroid – whether to use a cartesian or spheroidal distance calculation. Default is false
result_column_name – the name of the column containing the lof for each row. Default is “lof”
- Returns:
A PySpark DataFrame containing the lof for each row
Module contents
Algorithms for detecting outliers in spatial datasets.