''LocalOutlierFactor' object has no attribute 'negative_outlier_factor'
Herein is my setup for LOF score:
## Calculate each sample contrarian outlier score
outfactor=lof.negative_outlier_factor_
## Standardize the score
radius=(outfactor.max()-outfactor)/(outfactor.max()-outfactor.min())
iris.plot(kind="scatter",x="SepalWidthCm",y="PetalWidthCm",c="r",figsize=(10,6),label="data")
plt.scatter(iris["SepalWidthCm"],iris["PetalWidthCm"],s=800*radius,edgecolors="k",facecolors="none",label="LOF score")
plt.legend()
plt.grid()
plt.title("outliers score visualization")
plt.show()
and the error message appears as:
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_4140/2903391628.py in <module>
1 ## Calculate each sample contrarian outlier score
----> 2 outfactor=lof.negative_outlier_factor
3 ## Standardize the score
4 radius=(outfactor.max()-outfactor)/(outfactor.max()-outfactor.min())
5 iris.plot(kind="scatter",x="SepalWidthCm",y="PetalWidthCm",c="r",figsize=(10,6),label="data")
AttributeError: 'LocalOutlierFactor' object has no attribute 'negative_outlier_factor'
I have no clue how to deal with it because the LOF has been loaded.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
