LocalOutlierFactor (Beta)¶
LocalOutlierFactor(name: str,
n_neighbors: int = 20,
p: int = 2)
Creates a LocalOutlierFactor object by using the local outlier factor algorithm as defined by Markus M. Breunig, Hans-Peter Kriegel, Raymond T. Ng, and Jörg Sander. This object uses pure SQL to compute all the distances and final score.
⚠ Warning: This algorithm is computationally expensive; It uses a CROSS JOIN during the computation, the complexity of which is O(n * n), where n is the total number of elements. It will index all the elements of the table in order to be optimal (the CROSS JOIN will happen only with IDs which are integers). Since this algorithm uses the p-distance, it is highly sensitive to unnormalized data. A table will be created at the end of the learning phase.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
name | str | ❌ | Name of the the model. As it is not a built in model, this name will be to use to build the final table. |
n_neighbors | int | ✓ | Number of neighbors to consider when computing the score. |
p | int | ✓ | The p of the p-distance (distance metric used during the model computation). |
Attributes¶
After the object creation, all the parameters become attributes. The model will also create extra attributes when fitting the model:
| Name | Type | Description |
|---|---|---|
n_errors_ | int | Number of errors during the LOF computation. |
input_relation | str | Training relation. |
X | list | List of the predictors. |
key_columns | list | Columns not used during the algorithm computation, but will be to used to create the final relation. |
Methods¶
| Name | Description |
|---|---|
| fit | Trains the model. |
| get_attr | Returns the model attribute. |
| get_params | Returns the model parameters. |
| plot | Draws the model if the number of predictors is 2 or 3. |
| predict | Creates a vDataFrame of the model. |
| set_params | Sets the parameters of the model. |
Example¶
from verticapy.learn.neighbors import LocalOutlierFactor
model = LocalOutlierFactor(name = "public.LOF_heart")
display(model)
