0

I try to run this script in Power BI:

from pycaret.anomaly import *
dataset = get_outliers(dataset, ignore_features=['DEPT_NAME', 'MERCHANT', 'TRANS_DT'])

I got the script from https://pycaret.gitbook.io/docs/learn-pycaret/official-blog/anomaly-detector-in-power-bi-using-pycaret

But I get this error:

DataSource.Error: ADO.NET: Ρуŧнόл śςѓïрŧ êŗгôř.
<pi>NameError: name 'get_outliers' is not defined
</pi>
Detaljer:
    DataSourceKind=Python
    DataSourcePath=Python
    Message=Ρуŧнόл śςѓïрŧ êŗгôř.
<pi>NameError: name 'get_outliers' is not defined
</pi>
    ErrorCode=-2147467259

As I read it there is a problem with: get_outliers

I have no clue of what to do, I have searchede but I cant get any answer there solves my problem.

1 Answers1

1

I think you using PyCaret 3.x but in the tutorial is PyCaret 2.x. They remove get_outliers() in 3.x but the underlying of this function is the wrapper of the following steps

  1. setup()
  2. create_model()
  3. assign_model()

You need to write this way to get the same results as the tutorial

from pycaret.anomaly import *
setup(dataset, ignore_features=['DEPT_NAME', 'MERCHANT', 'TRANS_DT'], verbose=False)
c = create_model(model='knn', fraction=0.05)
dataset = assign_model(c, verbose=False)

power_bi_results

You can find implementation of get_outliers() in PyCaret 2.x from here and tutorial about anomaly detection in PyCaret 3.x from here

Tatchai S.
  • 315
  • 1
  • 3
  • 9