Implementation:Online ml River Utils Inspect
Appearance
| 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
- Repository: Online_ml_River
- File: river/utils/inspect.py
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