local_outlier_factor
Functions related to calculating the local outlier factor of a dataset.
local_outlier_factor(dataframe, k=20, geometry=None, approximate_knn=False, handle_ties=False, use_spheroid=False, result_column_name='lof')
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:
Name | Type | Description | Default |
---|---|---|---|
dataframe
|
DataFrame
|
apache sedona idDataframe containing the point geometries |
required |
k
|
int
|
number of nearest neighbors that will be considered for the LOF calculation |
20
|
geometry
|
Optional[str]
|
name of the geometry column |
None
|
approximate_knn
|
bool
|
whether to use approximate KNN. When false will use exact KNN join. Default is False |
False
|
handle_ties
|
bool
|
whether to handle ties in the k-distance calculation. Default is false |
False
|
use_spheroid
|
whether to use a cartesian or spheroidal distance calculation. Default is false |
False
|
|
result_column_name
|
str
|
the name of the column containing the lof for each row. Default is "lof" |
'lof'
|
Returns:
Type | Description |
---|---|
A PySpark DataFrame containing the lof for each row |