tw.insights
The Insights
class provides methods for extracting detailed insights from forecasting or anomaly detection models. It includes tools to analyze model properties and extract features, making it an essential tool for interpreting and understanding model behavior.
Class Initialization
To use the Insights
API, access it through the TangentWorks
class:
from tangent_works import TangentWorks
# Initialize TangentWorks
tw = TangentWorks()
# Access the Insights class
tw.insights
Methods
properties
tw.insights.properties(model=Dict[str, Any])
Retrieves and processes the variable properties of the given model, sorted by importance.
Parameters
model
(Dict[str, Any]): The model object containing variable properties.
Returns
pd.DataFrame
: A DataFrame containing:Variable names.
Importance scores, sorted in descending order.
Relative importance scores.
Examples
# Analyze model properties
properties_df = tw.insights.properties(model)
features
tw.insights.features(model=Dict[str, Any])
Extracts and processes the features used in the given model.
Parameters
model
(Dict[str, Any]): The model object containing feature terms.
Returns
pd.DataFrame
: A DataFrame containing:Model index.
Term index.
Feature name.
Feature importance.
Associated beta value.
Examples
# Extract features from the model
features_df = tw.insights.features(model)
Key Features
Analyze model properties: Understand the importance of variables in your model using
properties
.Feature extraction: Gain detailed insights into the features and terms used in your model with
features
.Comprehensive results: Outputs are provided as easy-to-use Pandas DataFrames for further analysis and visualization.
Dependencies
pandas
: Used for constructing and manipulating DataFrames.Tangent Works core modules: Handle model processing and feature extraction.