API Reference¶
Welcome to the k-diagram API reference. This section provides detailed information on the functions, classes, and modules included in the package.
The documentation here is largely auto-generated from the docstrings within the k-diagram source code. Ensure you have installed the package (see Installation) for the documentation build process to find the modules correctly.
Plotting Functions (kdiagram.plot)¶
This is the core module containing the specialized visualization functions, organized by their diagnostic purpose.
Uncertainty Visualization (kdiagram.plot.uncertainty)¶
Functions focused on visualizing prediction intervals, coverage, anomalies, drift, and other uncertainty-related diagnostics.
Polar plot comparing actual observed vs predicted values. |
|
Visualize magnitude and type of prediction-interval anomalies. |
|
Plot overall coverage scores for forecast intervals or points. |
|
Diagnose prediction-interval coverage on a polar plot. |
|
Polar plot showing consistency of prediction interval widths. |
|
Polar scatter plot visualizing prediction interval width. |
|
Visualize forecast drift across prediction horizons. |
|
Visualize multiple data series using polar scatter plots. |
|
Polar plot visualizing temporal drift of uncertainty width. |
|
Polar plot visualizing average velocity across locations. |
|
Plot a radial density ring to visualize a 1D distribution. |
|
Plot a polar heatmap to visualize a 2D density distribution. |
|
Plot a polar quiver plot to visualize vector data. |
Error Analysis (kdiagram.plot.errors)¶
Functions for diagnosing and visualizing model errors, focusing on systemic vs. random errors, comparing error distributions, and visualizing 2D uncertainty.
Plot polar error bands to visualize systemic vs random error. |
|
Plot polar violin plots to compare multiple error distributions. |
|
Plot polar error ellipses to visualize two-dimensional uncertainty. |
Probabilistic Diagnostics (kdiagram.plot.probabilistic)¶
Functions for the in-depth evaluation of probabilistic forecasts, assessing calibration, sharpness, and overall performance.
Plots a Polar Probability Integral Transform (PIT) Histogram. |
|
Plots a Polar Sharpness Diagram to compare forecast precision. |
|
Plots a Polar CRPS Comparison Diagram. |
|
Plots Polar Credibility Bands to visualize forecast uncertainty. |
|
Plots a Polar Calibration-Sharpness Diagram. |
Model Comparison (kdiagram.plot.comparison)¶
Functions for comparing multi-model performances using radar charts and reliability diagrams.
Plot multi-metric model performance comparison on a radar chart. |
|
Plot a reliability diagram (calibration plot) for one or more classification models. |
|
Plot a Polar Reliability Diagram (Calibration Spiral). |
|
Plot a polar bar chart comparing metrics across different horizons. |
Relationship Visualization (kdiagram.plot.relationship)¶
Functions for visualizing relationships between true values, predictions, and errors.
Visualize the relationship between true values and one or more prediction series on a polar (circular) scatter plot. |
|
Plots polar conditional quantile bands. |
|
Plots the relationship between forecast error and the true value. |
|
Plots the relationship between forecast error and predicted value. |
Feature-Based Visualization (kdiagram.plot.feature_based)¶
Functions for visualizing feature importance and influence patterns.
Create a radar chart visualizing feature-importance profiles. |
|
Plots a polar heatmap of feature interactions. |
|
Create a flexible polar 'fingerprint' (radar) chart. |
Contextual Diagnostics (kdiagram.plot.context)¶
Standard Cartesian plots that provide essential context for the main polar diagrams, covering time series, correlation, and error distribution analysis.
Plots one or more time series from a DataFrame. |
|
Plots a scatter plot of true vs predicted values. |
|
Plots a histogram and KDE of the forecast errors. |
|
Generates a Quantile-Quantile (Q-Q) plot of forecast errors. |
|
Plots the autocorrelation of forecast errors. |
|
Plots the partial autocorrelation of forecast errors. |
Classification Evaluation (kdiagram.plot.evaluation)¶
Functions for evaluating the performance of classification models, featuring novel polar adaptations of standard diagnostic tools.
Plots a Polar Receiver Operating Characteristic (ROC) Curve. |
|
Plots a Polar Precision-Recall (PR) Curve. |
|
Plots a Polar Confusion Matrix for binary classification. |
|
Plots a Polar Confusion Matrix for multiclass classification. |
|
Plots a Polar Confusion Matrix for multiclass classification. |
|
Plots a Polar Classification Report. |
|
Plots the Pinball Loss for each quantile of a forecast. |
|
Creates a Polar Performance Chart for regression models. |
Anomaly Diagnostics (kdiagram.plot.anomaly)¶
Functions for creating detailed visualizations of forecast failures (anomalies) and their characteristics.
Visualizes clustered anomaly severity using a polar scatter plot. |
|
Visualize anomaly severity as a polar profile or "fiery ring". |
|
Visualizes anomaly characteristics using a polar glyph plot. |
|
Visualizes anomaly severity in layered Cartesian coordinates. |
|
Visualizes clustered anomaly severity on a Cartesian plot. |
Taylor Diagram (kdiagram.plot.taylor_diagram)¶
Functions for evaluating model performance against a reference using Taylor Diagrams.
Plot a Taylor diagram to compare multiple predictions against a reference by visualizing their correlation and standard deviation. |
|
Plot Taylor Diagram with background color map. |
|
Plot a standard Taylor Diagram. |
Specialized Forecasting Metrics (kdiagram.metrics)¶
Functions for computing specialized scores for forecast evaluation, such as the Clustered Anomaly Severity (CAS) score.
Compute the Cluster-Aware Severity (CAS) score. |
|
Computes the Clustered Anomaly Severity (CAS) score. |
Utility Functions (kdiagram.utils)¶
Helper functions for data preparation, mathematical computations, and validations.
Bins data by a feature and computes aggregate statistics. |
|
Builds an interpolator to act as a Cumulative Distribution Function. |
|
Generate and validate quantile column names following naming conventions. |
|
Calculates the calibration error using the PIT and KS test. |
|
Calculates probabilistic scores for each observation. |
|
Computes the coverage score for a given prediction interval. |
|
Approximates the Continuous Ranked Probability Score (CRPS). |
|
Computes forecast errors for one or more models. |
|
Computes the width of one or more prediction intervals. |
|
Computes the Pinball Loss for a single quantile forecast. |
|
Computes the Probability Integral Transform (PIT) for each observation. |
|
Computes the Winkler score for a given prediction interval. |
|
Detect quantile columns in a DataFrame using naming patterns and value validation. |
|
Extract true and/or predicted values from a DataFrame. |
|
Reshape a wide DataFrame with time-embedded quantile columns into a tidy wide table with explicit temporal and quantile dimensions. |
|
Scale features to a specified range using a Min-Max approach. |
|
Reshapes multi-horizon forecast data from wide to long format. |
|
Convert a long/tidy-wide quantile table back to a time-embedded wide format with columns named like |
|
Plot histogram and Kernel Density Estimate (KDE) for uncertainty evaluation. |
|
Reshape a wide-format DataFrame with quantile columns into a DataFrame where the quantiles are separated into distinct columns for each quantile value. |
|
Save a Matplotlib figure robustly. |
Datasets (kdiagram.datasets)¶
Functions for loading sample datasets and generating synthetic data for examples and testing.
Generate a synthetic dataset for uncertainty diagnostics. |
|
Load the Zhongshan land subsidence prediction dataset. |
|
Generate synthetic cyclical data for relationship and temporal plots. |
|
Generate synthetic feature-importance data for fingerprint plots. |
|
Generate multi-model quantile forecast data for a single horizon. |
|
Generate a synthetic regression dataset with a configurable true process and multiple model prediction profiles. |
|
Generate a synthetic classification dataset with a configurable feature process and multiple model outputs (labels and/or probabilities). |
|
Generate synthetic data for Taylor diagrams. |
|
Generate a synthetic multi-period uncertainty dataset. |
Command-Line Interface (CLI)¶
In addition to the Python API, k-diagram also provides a
command-line interface for generating plots directly from your
terminal. This is an option for quick exploration and batch
processing without writing any Python code.
For a full guide to all available commands and their options, please see the CLI Reference.