liveBook · Manning

PyCaret

As explained in Outlier Detection in Python

An open-source Python library that provides low-code interfaces for machine learning workflows, including preprocessing, modeling, clustering, time-series analysis, and outlier detection.

PyCaret is a Python library that simplifies machine-learning workflows through consistent, low-code wrappers for preprocessing, feature engineering, modeling, clustering, time-series analysis, and outlier detection. It is especially useful for quickly preparing tabular data and comparing or assembling models. section 7.3

For outlier detection, PyCaret wraps a subset of PyOD detectors with a consistent interface. A typical workflow calls setup(), create_model(), and predict_model(); the resulting dataframe adds Anomaly and Anomaly Score columns. Binary labels are derived from detector scores using the selected contamination level. section 7.3

The setup() stage supplies much of PyCaret’s practical value:

  • Generate polynomial and interaction features, including squared features, to expose differences that original variables may hide. section 7.3
  • Create grouped feature sets while retaining the original variables. section 7.3
  • Remove detected outliers through a setup option when that workflow is appropriate. section 7.3
  • Integrate with MLFlow and support autoML and ensemble-building workflows. section 7.3

KNN anomaly detection

Install PyCaret, load or create test data, initialize anomaly detection with setup(data=df), create a KNN model with create_model('knn'), and score rows using predict_model(model=knn, data=df).

How Outlier Detection in Python covers it

How deep it goes
Explains installation, setup options, detector creation, prediction output, feature engineering, and contamination-based labeling.
Examples
Uses KNN detection on test data and demonstrates polynomial features, grouped features, outlier removal, and generated anomaly datasets.
What it assumes
Assumes Python data-handling familiarity while providing a simplified interface for detector setup, feature engineering, and prediction.
What you can do after
Apply PyCaret to preprocess data, create an outlier detector, generate anomaly scores, and obtain contamination-based labels.
How it connects
Connects preprocessing and feature engineering with PyOD detectors, scikit-learn-compatible ideas, MLFlow, autoML, and ensembles.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Outlier Detection in Python. The section links point to the parts of the book it draws on.