Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Online ml River Utils Inspect

From Leeroopedia
Revision as of 16:12, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Online_ml_River_Utils_Inspect.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Online_Learning, Model_Introspection
Last Updated 2026-02-08 16:00 GMT

Overview

Utilities for runtime inspection of model types and capabilities.

Description

Provides functions to determine a model's type at runtime, handling pipelines and wrappers where isinstance checks fail. Includes isclassifier, isregressor, istransformer, isanomalydetector, and more. Essential for River's internal routing and validation logic.

Usage

Use when writing generic code that needs to detect model capabilities, validate pipeline compatibility, or route data appropriately based on model type.

Code Reference

Source Location

Signature

def extract_relevant(model: base.Estimator):
    ...

def isclassifier(model):
    ...

def isregressor(model):
    ...

def istransformer(model):
    ...

def isanomalydetector(model):
    ...

def isclusterer(model):
    ...

def isdriftdetector(model):
    ...

Import

from river import utils

Usage Examples

from river import linear_model, preprocessing, utils, tree

# Check model types
model = linear_model.LogisticRegression()
print(f"Is classifier: {utils.inspect.isclassifier(model)}")  # True
print(f"Is regressor: {utils.inspect.isregressor(model)}")  # False

# Works with pipelines
pipeline = (
    preprocessing.StandardScaler() |
    tree.HoeffdingTreeClassifier()
)
print(f"Pipeline is classifier: {utils.inspect.isclassifier(pipeline)}")  # True

# Anomaly detection
from river import anomaly
detector = anomaly.HalfSpaceTrees()
print(f"Is anomaly detector: {utils.inspect.isanomalydetector(detector)}")  # True

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment