2

My question lies specifically in knn method in Anomaly Detection module of pycaret library. Usually number of k neighbors has to be specified. Like for example in PyOD library.

How to learn what number of neighbors knn uses in pycaret library? Or does it have a default value?

Weilire
  • 37
  • 6

1 Answers1

2

you can find the number of neighbors of the constructed knn model by printing it. By default, n_neighbors=5, radius=1.0.
I run the knn demo code locally, with:

python=3.6
pycaret=2.2.3
vscode
import pycaret
from pycaret.anomaly import *
from pycaret.datasets import get_data
anomaly = get_data('anomaly')
exp_name = setup(data = anomaly)

knn = create_model('knn') 

print("pausing") # set breakpoint here

In debugging mode, I get:
default knn para in pycaret

Further, you can set the parameter when call create_model, e.g. set the number of neighbors as 10:
set knn

JW Tang
  • 79
  • 3