Table of Contents
Inspection Tools Reference
Functions for inspecting, analyzing, and visualizing machine learning models.
ML.INSPECT Namespace
ML.INSPECT.GET_PARAMS()
Extracts parameters from a model or transformer.
Syntax:
=ML.INSPECT.GET_PARAMS(obj, transpose)
Parameters:
obj
(Object, Required): Model, transformer, or pipeline objecttranspose
(Boolean, Optional): Return wide format (default: FALSE)- FALSE: Returns long format (Parameter | Value columns)
- TRUE: Returns wide format (each parameter as a column)
Returns: DataFrame with model parameters
Use Case: Inspect model configuration, verify hyperparameters
Example:
# Get parameters from model
Cell A1: =ML.INSPECT.GET_PARAMS(trained_model)
Result:
# Parameter | Value
# C | 1.0
# kernel | rbf
# gamma | scale
# Get parameters in wide format
Cell B1: =ML.INSPECT.GET_PARAMS(trained_model, TRUE)
Result:
# C | kernel | gamma
# 1.0 | rbf | scale
ML.INSPECT.DECISION_BOUNDARY()
Extracts decision boundary contour points for visualization.
Syntax:
=ML.INSPECT.DECISION_BOUNDARY(model, X, response_method, mesh_step, class_pair, feature_indices, other_features_values, margin)
Parameters:
model
(Object, Required): Fitted classifierX
(Object, Required): Training data (for boundary range)response_method
(String, Optional): Method to use (default: “predict”)- “predict”: Use predictions
- “decision_function”: Use decision function values
mesh_step
(Number, Optional): Grid resolution (default: 0.05)- Smaller = smoother boundary, more points
class_pair
(Array, Optional): Class pair for multiclass (default: [0,1])- For multiclass with decision_function
feature_indices
(Tuple, Optional): Which features to use (default: (0,1))- Tuple of two feature indices for boundary
other_features_values
(Dict, Optional): Values for other features- Dict mapping feature index to value
- Default: Uses mean values
margin
(Number, Optional): Boundary margin (default: 0.1)
Returns: DataFrame with boundary coordinates
Use Case: Visualize decision boundaries, understand model behavior
Example:
# Basic decision boundary (first two features)
Cell A1: =ML.INSPECT.DECISION_BOUNDARY(trained_svm, X_train)
Result:
# feature_0 | feature_1
# 2.34 | 3.45
# 2.35 | 3.46
# ...
# Boundary for specific features
Cell B1: =ML.INSPECT.DECISION_BOUNDARY(trained_model, X_train, "predict", 0.02, {0,1}, {2,3})
# Use with DataFrame (preserves column names)
Cell C1: =ML.INSPECT.DECISION_BOUNDARY(trained_model, df_train, "predict", 0.05, {0,1}, {0,1})
Result:
# sepal_length | sepal_width
# 5.1 | 3.5
# 5.2 | 3.6
# ...
Common Patterns
Inspect Model Configuration
# Train model
Cell A1: =ML.CLASSIFICATION.SVM(10, "rbf", 3, "scale", 0.0)
Cell B1: =ML.FIT(A1, X_train, y_train)
# Get all parameters
Cell C1: =ML.INSPECT.GET_PARAMS(B1)
# Verify configuration
# Check that C=10, kernel=rbf, etc.
Inspect Pipeline Components
# Create pipeline
Cell A1: =ML.PREPROCESSING.STANDARD_SCALER()
Cell A2: =ML.CLASSIFICATION.SVM()
Cell B1: =ML.PIPELINE(A1, A2)
# Fit pipeline
Cell C1: =ML.FIT(B1, X_train, y_train)
# Get pipeline parameters (shows all steps)
Cell D1: =ML.INSPECT.GET_PARAMS(C1)
Result:
# Model | Parameter | Value
# standardscaler | with_mean | True
# standardscaler | with_std | True
# svc | C | 1.0
# svc | kernel | rbf
Visualize 2D Decision Boundary
# Train binary classifier
Cell A1: =ML.DATASETS.IRIS()
Cell B1: =ML.DATA.SELECT_COLUMNS(A1, {0,1}) # First 2 features
Cell C1: =ML.DATA.SELECT_COLUMNS(A1, 4) # Target
Cell D1: =ML.CLASSIFICATION.SVM(1.0, "rbf")
Cell E1: =ML.FIT(D1, B1, C1)
# Extract decision boundary
Cell F1: =ML.INSPECT.DECISION_BOUNDARY(E1, B1, "predict", 0.05, {0,1}, {0,1})
# Create visualization:
# 1. Create scatter plot of B1 data points (color by C1 classes)
# 2. Add line chart of F1 boundary points
# Result: Boundary overlaid on data
Multi-Class Decision Boundaries
# Train multi-class classifier
Cell A1: =ML.DATASETS.IRIS() # 3 classes
Cell B1: =ML.DATA.SELECT_COLUMNS(A1, {0,1})
Cell C1: =ML.DATA.SELECT_COLUMNS(A1, 4)
Cell D1: =ML.CLASSIFICATION.SVM(1.0, "rbf")
Cell E1: =ML.FIT(D1, B1, C1)
# Get boundaries for each class pair
Cell F1: =ML.INSPECT.DECISION_BOUNDARY(E1, B1, "decision_function", 0.05, {0,1}, {0,1})
Cell F2: =ML.INSPECT.DECISION_BOUNDARY(E1, B1, "decision_function", 0.05, {0,2}, {0,1})
Cell F3: =ML.INSPECT.DECISION_BOUNDARY(E1, B1, "decision_function", 0.05, {1,2}, {0,1})
# Plot all three boundaries
High-Dimensional Boundary (2D Slice)
# Train on 4D data
Cell A1: =ML.DATASETS.IRIS()
Cell B1: =ML.DATA.SELECT_COLUMNS(A1, {0,1,2,3}) # 4 features
Cell C1: =ML.DATA.SELECT_COLUMNS(A1, 4)
Cell D1: =ML.CLASSIFICATION.SVM()
Cell E1: =ML.FIT(D1, B1, C1)
# Visualize boundary for features 0 and 1
# Fix features 2 and 3 at specific values
Cell F1: =ML.INSPECT.DECISION_BOUNDARY(E1, B1, "predict", 0.05, {0,1}, {0,1}, {2:5.5, 3:2.0})
# This shows boundary in 2D slice where feature2=5.5, feature3=2.0
Compare Parameter Settings
# Create multiple models with different params
Cell A1: =ML.CLASSIFICATION.SVM(0.1, "rbf")
Cell A2: =ML.CLASSIFICATION.SVM(1.0, "rbf")
Cell A3: =ML.CLASSIFICATION.SVM(10.0, "rbf")
# Train all
Cell B1: =ML.FIT(A1, X_train, y_train)
Cell B2: =ML.FIT(A2, X_train, y_train)
Cell B3: =ML.FIT(A3, X_train, y_train)
# Get params in wide format for comparison
Cell C1: =ML.INSPECT.GET_PARAMS(B1, TRUE)
Cell C2: =ML.INSPECT.GET_PARAMS(B2, TRUE)
Cell C3: =ML.INSPECT.GET_PARAMS(B3, TRUE)
# Easy to compare C values: 0.1, 1.0, 10.0
Inspect Grid Search Results
# Run grid search
Cell A1: =ML.CLASSIFICATION.SVM()
# ... parameter grid setup ...
Cell B1: =ML.EVAL.GRID_SEARCH(A1, param_grid, "accuracy", 5, TRUE)
Cell C1: =ML.FIT(B1, X_train, y_train)
# Get best model parameters
Cell D1: =ML.EVAL.BEST_PARAMS(C1)
# Get parameters of best model (includes fitted values)
Cell E1: =ML.INSPECT.GET_PARAMS(C1)
Boundary Smoothness Comparison
# Train model
Cell A1: =ML.CLASSIFICATION.SVM(1.0, "rbf")
Cell B1: =ML.FIT(A1, X_train, y_train)
# Coarse boundary (fast)
Cell C1: =ML.INSPECT.DECISION_BOUNDARY(B1, X_train, "predict", 0.1)
# Fine boundary (smooth, slower)
Cell C2: =ML.INSPECT.DECISION_BOUNDARY(B1, X_train, "predict", 0.02)
# Compare point count
Cell D1: =ROWS(C1#) # Fewer points
Cell D2: =ROWS(C2#) # More points
Tips and Best Practices
-
GET_PARAMS Usage
- Check model configuration before training
- Verify parameters after grid search
- Document model settings
- Debug unexpected behavior
-
Pipeline Inspection
- Shows all steps with step__ prefix
- Verify preprocessing parameters
- Check model configuration in pipeline
- Useful for debugging complex workflows
-
Decision Boundary Visualization
- 2D only: Can only visualize in 2 dimensions
- Mesh step: 0.05 good default, 0.02 for smooth
- Response method:
- “predict”: Clearer boundaries
- “decision_function”: Shows confidence regions
-
Handling High Dimensions
- Select two most important features
- Use PCA to reduce to 2D first
- Fix other features at meaningful values
- Consider multiple 2D slices
-
Visualization Tips
1. Get boundary points with DECISION_BOUNDARY 2. Create scatter plot of training data 3. Color points by class 4. Add boundary as line/contour 5. Adjust mesh_step for smoothness
-
Performance Considerations
- Smaller mesh_step = more points, slower
- Larger data range = more computation
- Consider sampling large datasets
- Cache boundary calculations
-
Common Use Cases
Model Understanding: GET_PARAMS → verify config Debugging: GET_PARAMS → check all parameters Visualization: DECISION_BOUNDARY → plot boundaries Comparison: Multiple boundaries → understand differences
-
Boundary Interpretation
- Linear SVM: Straight boundary
- RBF SVM: Curved boundary
- Polynomial: Polynomial curve
- Complex models: More intricate boundaries
Related Functions
- ML.FIT() - Train models to inspect
- ML.EVAL.BEST_PARAMS() - Extract best parameters
- ML.PIPELINE() - Create inspectable pipelines
- Classification Models - Models to visualize