> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Local Outlier Factor Python Module

Functions related to calculating the local outlier factor of a dataset.

## local\_outlier\_factor

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.

```python theme={"system"}
def local_outlier_factor(dataframe: DataFrame, k: int, geometry: Optional[str], approximate_knn: bool, handle_ties: bool, use_spheroid, result_column_name: str)
```

### Parameters

<ParamField path="dataframe" type="DataFrame" required>
  apache sedona idDataframe containing the point geometries
</ParamField>

<ParamField path="k" type="int" required>
  number of nearest neighbors that will be considered for the LOF calculation
</ParamField>

<ParamField path="geometry" type="Optional[str]">
  name of the geometry column
</ParamField>

<ParamField path="approximate_knn" type="bool" required>
  whether to use approximate KNN. When false will use exact KNN join. Default is False
</ParamField>

<ParamField path="handle_ties" type="bool" required>
  whether to handle ties in the k-distance calculation. Default is false
</ParamField>

<ParamField path="use_spheroid" type="bool" required>
  whether to use a cartesian or spheroidal distance calculation. Default is false
</ParamField>

<ParamField path="result_column_name" type="str" required>
  the name of the column containing the lof for each row. Default is "lof"
</ParamField>

### Returns

A PySpark DataFrame containing the lof for each row.

### Usage Examples

```python theme={"system"}
from local_outlier_factor import *

# Example usage of local_outlier_factor
result = local_outlier_factor(dataframe=example_value, k=example_value, geometry=example_value)
```
