July 2019
Beginner to intermediate
740 pages
16h 52m
English
The local outlier factor (LOF) algorithm scores all points based on the ratio of the density around each point to that of its nearest neighbors. Points that are considered normal will have similar densities to their neighbors; those with few others nearby will be considered abnormal.
Let's build another pipeline, but swap out the isolation forest for LOF:
>>> from sklearn.neighbors import LocalOutlierFactor>>> from sklearn.pipeline import Pipeline>>> from sklearn.preprocessing import StandardScaler>>> lof_pipeline = Pipeline([... ('scale', StandardScaler()),... ('lof', LocalOutlierFactor() ...Read now
Unlock full access