coco_pipe.viz.decoding#
Static visualization helpers for decoding result tables.
Functions#
|
Plot an aggregated confusion matrix from decoding diagnostics. |
|
Plot receiver-operating-characteristic curves. |
|
Plot precision-recall curves from decoding diagnostics. |
|
Plot calibration reliability curves. |
|
Plot fold-level scalar score distributions by model and metric. |
|
Plot mean temporal decoding score curves. |
|
Plot a train-time by test-time temporal generalization matrix. |
|
Plot temporal statistical assessment results. |
|
Plot observed scalar scores against null interval summaries. |
|
Plot neural training-history artifacts. |
|
Plot aggregate scalar decoding scores by model and metric. |
|
Plot model-comparison score differences. |
|
Plot fit-time diagnostics by model or fold. |
|
Plot probability-quality diagnostics. |
|
Plot per-unit prediction accuracy diagnostics. |
|
Plot group-level prediction accuracy summaries. |
|
Plot regression prediction diagnostics. |
|
Plot compact hyperparameter-search results. |
|
Plot ranked feature importances. |
|
Plot feature-selection stability. |
|
Plot univariate feature-selector scores. |
|
Plot a topomap from sensor-level decoding values. |
|
Plot feature-family importance summarized by sensor. |
|
Plot feature importances for one sensor. |
|
Plot a sensor topomap for one feature family. |
|
Plot labelled estimates for cross-result head-to-head comparisons. |
|
Plot paired deltas with optional confidence intervals. |
Module Contents#
- coco_pipe.viz.decoding.plot_confusion_matrix(result_or_matrix, model=None, fold=None, title=None, ax=None, figsize=None)#
Plot an aggregated confusion matrix from decoding diagnostics.
- Parameters:
result_or_matrix (Any) – Experiment result with
get_confusion_matrices()or a tidy confusion matrix DataFrame containingTrueLabel,PredictedLabel, andValue.model (str | None) – Optional model name used to filter rows before aggregation.
fold (int | None) – Optional fold index used to filter rows before aggregation.
title (str | None) – Optional axes title. Defaults to
"Confusion Matrix".ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when
axis not provided.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_confusion_matrixInteractive Plotly version.
plot_roc_curveReceiver-operating-characteristic curve.
plot_probability_diagnosticsProbability-calibration quality metrics.
plot_decoding_scoresAggregate scalar score summary.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "TrueLabel": list("AABB"), ... "PredictedLabel": list("ABAB"), ... "Value": [5, 1, 2, 4], ... } ... ) >>> fig, ax = viz.plot_confusion_matrix(df)
- coco_pipe.viz.decoding.plot_roc_curve(result_or_curve, model=None, fold=None, title=None, ax=None, figsize=None, mean_only=False)#
Plot receiver-operating-characteristic curves.
- Parameters:
result_or_curve (Any) – Experiment result with
get_roc_curve()or a DataFrame containingModel,FPR, andTPR. OptionalFoldandClasscolumns are used for grouping.model (str | None) – Optional model name to display.
fold (int | None) – Optional fold index to display.
title (str | None) – Optional axes title. Defaults to
"ROC Curve".ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
mean_only (bool) – If True, interpolate fold curves onto a common x-grid and draw the mean curve with a standard-deviation band.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_roc_curveInteractive Plotly version.
plot_pr_curvePrecision-recall curve.
plot_calibration_curveProbability calibration reliability curve.
plot_confusion_matrixPredicted-vs-true class heatmap.
Examples
>>> import numpy as np, pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": "SVM", ... "FPR": np.linspace(0, 1, 10), ... "TPR": np.linspace(0, 1, 10) ** 0.5, ... } ... ) >>> fig, ax = viz.plot_roc_curve(df)
- coco_pipe.viz.decoding.plot_pr_curve(result_or_curve, model=None, fold=None, title=None, ax=None, figsize=None, mean_only=False)#
Plot precision-recall curves from decoding diagnostics.
- Parameters:
result_or_curve (Any) – Experiment result with
get_pr_curve()or a DataFrame containingModel,Recall, andPrecision. OptionalFoldandClasscolumns are used for grouping.model (str | None) – Optional model name to display.
fold (int | None) – Optional fold index to display.
title (str | None) – Optional axes title. Defaults to
"Precision-Recall Curve".ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
mean_only (bool) – If True, interpolate fold curves onto a common recall grid and draw the mean curve with a standard-deviation band.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_pr_curveInteractive Plotly version.
plot_roc_curveReceiver-operating-characteristic curve.
plot_calibration_curveProbability calibration reliability curve.
Examples
>>> import numpy as np, pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": "SVM", ... "Recall": np.linspace(0, 1, 10), ... "Precision": np.linspace(1, 0.5, 10), ... } ... ) >>> fig, ax = viz.plot_pr_curve(df)
- coco_pipe.viz.decoding.plot_calibration_curve(result_or_curve, model=None, fold=None, title=None, ax=None, figsize=None, mean_only=False)#
Plot calibration reliability curves.
- Parameters:
result_or_curve (Any) – Experiment result with
get_calibration_curve()or a DataFrame containingModel,MeanPredictedProbability, andFractionPositive.model (str | None) – Optional model name to display.
fold (int | None) – Optional fold index to display.
title (str | None) – Optional axes title. Defaults to
"Calibration Curve".ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
mean_only (bool) – If True, interpolate fold curves onto a common probability grid and draw the mean curve with a standard-deviation band.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_calibration_curveInteractive Plotly version.
plot_roc_curveReceiver-operating-characteristic curve.
plot_pr_curvePrecision-recall curve.
plot_probability_diagnosticsScalar probability-quality metrics.
Examples
>>> import numpy as np, pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": "SVM", ... "MeanPredictedProbability": np.linspace(0, 1, 10), ... "FractionPositive": np.linspace(0.05, 0.95, 10), ... } ... ) >>> fig, ax = viz.plot_calibration_curve(df)
- coco_pipe.viz.decoding.plot_fold_score_dispersion(result_or_scores, metric=None, model=None, title=None, ax=None, figsize=None)#
Plot fold-level scalar score distributions by model and metric.
- Parameters:
result_or_scores (Any) – Experiment result with
get_detailed_scores()or a detailed score DataFrame containing scalarValuerows.metric (str | None) – Optional metric name used to filter scores.
model (str | None) – Optional model name used to filter scores.
title (str | None) – Optional axes title. Defaults to
"Fold Score Dispersion".ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_fold_score_dispersionInteractive Plotly version.
plot_decoding_scoresAggregate score summary with error bars.
plot_model_comparisonPairwise score-difference plot.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": "SVM", ... "Fold": [0, 1, 2, 3, 4], ... "Metric": "accuracy", ... "Value": [0.82, 0.79, 0.85, 0.81, 0.83], ... } ... ) >>> fig, ax = viz.plot_fold_score_dispersion(df)
- coco_pipe.viz.decoding.plot_temporal_score_curve(result_or_scores, metric=None, model=None, title=None, ax=None, figsize=None, smooth_window=None)#
Plot mean temporal decoding score curves.
- Parameters:
result_or_scores (Any) – Experiment result with
get_temporal_score_summary()or a DataFrame containingModel,Metric,Time, andMean.metric (str | None) – Optional metric name used to filter temporal scores.
model (str | None) – Optional model name used to filter temporal scores.
title (str | None) – Optional axes title. Defaults to
"Temporal Decoding Value".ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
smooth_window (int | None)
- Returns:
The created or reused figure and axes.
- Return type:
Notes
Non-numeric time labels are plotted at integer positions and displayed as rotated tick labels.
See also
coco_pipe.viz.interactive.decoding.plot_temporal_score_curveInteractive Plotly version.
plot_temporal_generalization_matrixTrain-time x test-time heatmap.
plot_temporal_statistical_assessmentTemporal curve with permutation null band.
plot_null_interval_summaryScalar null-interval summary per model.
Examples
>>> import numpy as np, pandas as pd >>> from coco_pipe.viz import decoding as viz >>> t = np.linspace(0, 0.5, 10) >>> df = pd.DataFrame( ... { ... "Model": "SVM", ... "Metric": "accuracy", ... "Time": t, ... "Mean": 0.5 + 0.1 * np.arange(10) / 10, ... } ... ) >>> fig, ax = viz.plot_temporal_score_curve(df)
- coco_pipe.viz.decoding.plot_temporal_generalization_matrix(result_or_scores, metric=None, model=None, title=None, ax=None, figsize=None)#
Plot a train-time by test-time temporal generalization matrix.
- Parameters:
result_or_scores (Any) – Experiment result with
get_temporal_score_summary()or a DataFrame containingModel,Metric,TrainTime,TestTime, andMean.metric (str | None) – Optional metric name. A single model/metric pair must remain after filtering.
model (str | None) – Optional model name. A single model/metric pair must remain after filtering.
title (str | None) – Optional axes title. Defaults to
"<model> / <metric>".ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_temporal_generalization_matrixInteractive Plotly version.
plot_temporal_score_curveMean temporal score curve over time.
plot_temporal_statistical_assessmentTemporal curve with permutation null band.
Examples
>>> import numpy as np, pandas as pd >>> from coco_pipe.viz import decoding as viz >>> times = np.linspace(0, 0.5, 5) >>> rows = [ ... { ... "Model": "SVM", ... "Metric": "accuracy", ... "TrainTime": t1, ... "TestTime": t2, ... "Mean": 0.7, ... } ... for t1 in times ... for t2 in times ... ] >>> fig, ax = viz.plot_temporal_generalization_matrix(pd.DataFrame(rows))
- coco_pipe.viz.decoding.plot_temporal_statistical_assessment(result_or_assessment, metric=None, model=None, title=None, ax=None, figsize=None)#
Plot temporal statistical assessment results.
- Parameters:
result_or_assessment (Any) – Experiment result with
get_statistical_assessment()or an assessment DataFrame containingModel,Metric,Observed, andTime.metric (str | None) – Optional metric name. A single model/metric pair must remain after filtering.
model (str | None) – Optional model name. A single model/metric pair must remain after filtering.
title (str | None) – Optional axes title. Defaults to a model/metric statistical-assessment title.
ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
Notes
NullLowerandNullUpperare rendered as a null band when present.Significantrows are overlaid as square markers.See also
coco_pipe.viz.interactive.decoding.plot_temporal_statistical_assessmentInteractive Plotly version.
plot_temporal_score_curveMean temporal score curve over time.
plot_null_interval_summaryScalar null-interval summary per model.
Examples
>>> import numpy as np, pandas as pd >>> from coco_pipe.viz import decoding as viz >>> rng = np.random.default_rng(42) >>> t = np.linspace(0, 0.5, 10) >>> df = pd.DataFrame( ... { ... "Model": "SVM", ... "Metric": "accuracy", ... "Time": t, ... "Observed": 0.5 + 0.1 * rng.normal(size=10), ... } ... ) >>> fig, ax = viz.plot_temporal_statistical_assessment(df)
- coco_pipe.viz.decoding.plot_null_interval_summary(result_or_assessment, metric=None, model=None, title=None, ax=None, figsize=None)#
Plot observed scalar scores against null interval summaries.
- Parameters:
result_or_assessment (Any) – Experiment result with
get_statistical_assessment()or an assessment DataFrame containingModel,Metric, andObserved.metric (str | None) – Optional metric name used to filter assessment rows.
model (str | None) – Optional model name used to filter assessment rows.
title (str | None) – Optional axes title. Defaults to
"Null Interval Summary".ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
Notes
NullLower/NullUpperare drawn as error intervals around their midpoint.NullMedianis shown as an optional marker series.See also
coco_pipe.viz.interactive.decoding.plot_null_interval_summaryInteractive Plotly version.
plot_temporal_statistical_assessmentSignificance-annotated temporal heatmap.
plot_decoding_scoresAggregate scalar score summary.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": ["SVM", "SVM"], ... "Metric": ["accuracy", "accuracy"], ... "Observed": [0.72, 0.68], ... "NullLower": [0.45, 0.44], ... "NullUpper": [0.55, 0.54], ... } ... ) >>> fig, ax = viz.plot_null_interval_summary(df)
- coco_pipe.viz.decoding.plot_training_history(result_or_artifacts, model=None, title=None, ax=None, figsize=None)#
Plot neural training-history artifacts.
- Parameters:
result_or_artifacts (Any) – Experiment result with
get_model_artifacts()or an artifact DataFrame containingModel,Key,ArtifactType, andValue. History values are expected to be records keyed by epoch and metric names.model (str | None) – Optional model name used to filter artifacts.
title (str | None) – Optional axes title. Defaults to
"Training History".ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_training_historyInteractive Plotly version.
plot_fit_diagnosticsFit-time diagnostics by model or fold.
plot_decoding_scoresAggregate scalar score summary.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> history = { ... "epoch": [1, 2, 3], ... "loss": [0.9, 0.7, 0.5], ... "val_loss": [1.0, 0.8, 0.65], ... } >>> df = pd.DataFrame( ... { ... "Model": ["DNN"], ... "Key": ["history"], ... "ArtifactType": ["training_history"], ... "Value": [history], ... } ... ) >>> fig, ax = viz.plot_training_history(df)
- coco_pipe.viz.decoding.plot_decoding_scores(result, metric=None, model=None, kind='point', aggregate='mean', ax=None, figsize=None)#
Plot aggregate scalar decoding scores by model and metric.
- Parameters:
result (Any) – Experiment result with
get_detailed_scores()or a detailed score DataFrame containing scalarValuerows.metric (str | None) – Optional metric name used to filter scores.
model (str | None) – Optional model name used to filter scores.
kind (Literal['point', 'bar', 'box']) – Plot type:
"point"for aggregate +/- SEM,"bar"for bar summaries, or"box"for fold-level distributions.aggregate (Literal['mean', 'median']) – Summary statistic used by
"point"and"bar"plots.ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_decoding_scoresInteractive Plotly version.
plot_model_comparisonScore differences between model pairs.
plot_fold_score_dispersionPer-fold score spread.
plot_null_interval_summaryObserved scores versus null bands.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": ["SVM"] * 5, ... "Metric": ["accuracy"] * 5, ... "Type": ["detailed_score"] * 5, ... "Value": [0.71, 0.73, 0.69, 0.74, 0.70], ... } ... ) >>> fig, ax = viz.plot_decoding_scores(df)
- coco_pipe.viz.decoding.plot_model_comparison(result, metric='accuracy', reference=None, paired=True, ax=None, figsize=None)#
Plot model-comparison score differences.
- Parameters:
result (Any) – Experiment result or a comparison DataFrame. DataFrames must contain a
Differencecolumn and may includeModelA,ModelB,CILower, andCIUpper.metric (str) – Metric used when computing comparisons from an experiment result.
reference (str | None) – Optional reference model. When provided with
paired=True, all other models are compared against this model.paired (bool) – If True and
referenceis provided, usecompare_models_paired. Otherwise usecompare_modelswhen available. Results with only detailed scores fall back to mean-score differences.ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_model_comparisonInteractive Plotly version.
plot_decoding_scoresAggregate scalar score summary.
plot_fold_score_dispersionPer-fold score spread.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "ModelA": ["SVM", "SVM"], ... "ModelB": ["LDA", "RF"], ... "Difference": [0.05, -0.02], ... "CILower": [0.01, -0.06], ... "CIUpper": [0.09, 0.02], ... } ... ) >>> fig, ax = viz.plot_model_comparison(df)
- coco_pipe.viz.decoding.plot_fit_diagnostics(result, *, by='Model', show_warnings=True, kind='bar', ax=None, figsize=None)#
Plot fit-time diagnostics by model or fold.
- Parameters:
result (Any) – Experiment result with
get_fit_diagnostics()or a diagnostics DataFrame containingTotalTimeplus the selectedbycolumn.by (Literal['Model', 'Fold']) – Column used for grouping, usually
"Model"or"Fold".show_warnings (bool) – If True, annotate the plot with the number of non-null
WarningMessageentries when present.kind (Literal['bar', 'box']) – Plot type:
"bar"for mean total time or"box"for grouped total-time distributions.ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_fit_diagnosticsInteractive Plotly version.
plot_training_historyNeural training-history artifacts.
plot_decoding_scoresAggregate scalar score summary.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": ["SVM", "SVM", "LDA", "LDA"], ... "Fold": [0, 1, 0, 1], ... "TotalTime": [1.2, 1.3, 0.5, 0.6], ... } ... ) >>> fig, ax = viz.plot_fit_diagnostics(df)
- coco_pipe.viz.decoding.plot_probability_diagnostics(result, model=None, metric=None, ax=None, figsize=None)#
Plot probability-quality diagnostics.
- Parameters:
result (Any) – Experiment result with
get_probability_diagnostics()or a DataFrame containingModel,Metric, andValue.model (str | None) – Optional model name used to filter diagnostics.
metric (str | None) – Optional diagnostic metric used to filter rows.
ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_probability_diagnosticsInteractive Plotly version.
plot_calibration_curveCalibration curve for probability estimates.
plot_confusion_matrixAggregated confusion matrix.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": ["SVM", "SVM"], ... "Metric": ["brier_score", "log_loss"], ... "Value": [0.18, 0.42], ... } ... ) >>> fig, ax = viz.plot_probability_diagnostics(df)
- coco_pipe.viz.decoding.plot_subject_diagnostics(result, unit='Subject', metric='accuracy', model=None, kind='strip', ax=None, figsize=None)#
Plot per-unit prediction accuracy diagnostics.
- Parameters:
result (Any) – Experiment result with
get_predictions()or a prediction DataFrame containingModel,y_true,y_pred, and the selectedunitcolumn.unit (str) – Metadata column used as the unit of aggregation, such as
"Subject".metric (str) – Metric to compute. Currently only
"accuracy"is supported.model (str | None) – Optional model name used to filter predictions.
kind (Literal['strip', 'dot', 'caterpillar']) – Plot type.
"strip"and"dot"show one point per unit grouped by model."caterpillar"shows sorted unit scores with horizontal stems.ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_subject_diagnosticsInteractive Plotly version.
plot_group_summaryGroup-level accuracy summaries.
plot_decoding_scoresAggregate scalar score summary.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": ["SVM"] * 6, ... "Subject": ["S1", "S1", "S2", "S2", "S3", "S3"], ... "Fold": [0, 1, 0, 1, 0, 1], ... "y_true": [0, 1, 1, 0, 0, 1], ... "y_pred": [0, 1, 0, 0, 0, 1], ... } ... ) >>> fig, ax = viz.plot_subject_diagnostics(df)
- coco_pipe.viz.decoding.plot_group_summary(result, group='Group', metric='accuracy', model=None, kind='point', ax=None, figsize=None)#
Plot group-level prediction accuracy summaries.
- Parameters:
result (Any) – Experiment result with
get_predictions()or a prediction DataFrame containingModel,Fold,y_true,y_pred, and the selected grouping column.group (str) – Prediction metadata column used to define groups.
metric (str) – Metric to compute. Currently only
"accuracy"is supported.model (str | None) – Optional model name used to filter predictions.
kind (Literal['point', 'violin']) – Plot type:
"point"for mean +/- SEM or"violin"for fold-level distributions.ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_group_summaryInteractive Plotly version.
plot_subject_diagnosticsPer-subject accuracy diagnostics.
plot_decoding_scoresAggregate scalar score summary.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": ["SVM"] * 8, ... "Group": ["A"] * 4 + ["B"] * 4, ... "Fold": [0, 1, 2, 3] * 2, ... "y_true": [0, 1, 1, 0, 0, 1, 0, 1], ... "y_pred": [0, 1, 0, 0, 0, 1, 0, 1], ... } ... ) >>> fig, ax = viz.plot_group_summary(df)
- coco_pipe.viz.decoding.plot_regression_diagnostics(result, model=None, fold=None, kind='scatter', ax=None, figsize=None)#
Plot regression prediction diagnostics.
- Parameters:
result (Any) – Experiment result with
get_predictions()or a prediction DataFrame containing numericy_trueandy_predcolumns.model (str | None) – Optional model name used to filter predictions.
fold (int | None) – Optional fold index used to filter predictions.
kind (Literal['scatter', 'residual', 'bin']) – Plot type:
"scatter"for observed vs predicted,"residual"for residuals vs predicted, or"bin"for binned mean residuals.ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_regression_diagnosticsInteractive Plotly version.
plot_decoding_scoresAggregate scalar score summary.
plot_confusion_matrixClassification confusion matrix.
Examples
>>> import numpy as np, pandas as pd >>> from coco_pipe.viz import decoding as viz >>> rng = np.random.default_rng(42) >>> y = rng.standard_normal(40) >>> df = pd.DataFrame( ... {"Model": "Ridge", "y_true": y, "y_pred": y + 0.1 * rng.standard_normal(40)} ... ) >>> fig, ax = viz.plot_regression_diagnostics(df)
- coco_pipe.viz.decoding.plot_search_results(result, model=None, top_n=None, ax=None, figsize=None)#
Plot compact hyperparameter-search results.
- Parameters:
result (Any) – Experiment result with
get_search_results()or a search-results DataFrame containingModel,Rank, andMeanTestScore.model (str | None) – Optional model name used to filter search rows.
top_n (int | None) – Optional positive number of top-ranked candidates to keep per model.
ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_search_resultsInteractive Plotly version.
plot_model_comparisonScore differences between model pairs.
plot_decoding_scoresAggregate scalar score summary.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": ["SVM"] * 3, ... "Rank": [1, 2, 3], ... "MeanTestScore": [0.80, 0.78, 0.75], ... } ... ) >>> fig, ax = viz.plot_search_results(df)
- coco_pipe.viz.decoding.plot_feature_importance(result, model=None, top_n=25, signed=False, absolute=False, ax=None, figsize=None, title=None)#
Plot ranked feature importances.
- Parameters:
result (Any) – Experiment result with
get_feature_importances(), a feature importance DataFrame, or a mapping/sequence coercible to a numeric Series. Non-numeric sequences are delegated to the dimensionality reduction feature-importance plot.model (str | None) – Optional model name used to filter importances.
top_n (int | None) – Optional number of highest-magnitude features to display.
signed (bool) – If True, use a diverging palette when plotting signed values.
absolute (bool) – If True, rank and display absolute importance values.
ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
title (str | None) – Optional axes title. Defaults to
"Feature Importance".
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_feature_importanceInteractive Plotly version.
plot_feature_stabilityFeature-selection stability across folds.
plot_feature_scoresUnivariate feature-selector scores.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": ["SVM"] * 4, ... "FeatureName": ["f1", "f2", "f3", "f4"], ... "Mean": [0.5, 0.3, 0.15, 0.05], ... } ... ) >>> fig, ax = viz.plot_feature_importance(df)
- coco_pipe.viz.decoding.plot_feature_stability(result, model=None, top_n=25, kind='bar', ax=None, figsize=None)#
Plot feature-selection stability.
- Parameters:
result (Any) – Experiment result or DataFrame.
kind="bar"expectsget_feature_stability()data withFeatureNameandSelectionFrequency.kind="heatmap"first triesget_selected_features()data withFold,FeatureName, andSelected.model (str | None) – Optional model name used to filter feature rows.
top_n (int | None) – Optional number of most stable features to display.
kind (Literal['bar', 'heatmap']) – Plot type:
"bar"for mean selection frequency or"heatmap"for fold-by-feature selected masks.ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_feature_stabilityInteractive Plotly version.
plot_feature_importanceRanked feature importances.
plot_feature_scoresUnivariate feature-selector scores.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": ["SVM"] * 3, ... "FeatureName": ["f1", "f2", "f3"], ... "SelectionFrequency": [0.9, 0.6, 0.4], ... } ... ) >>> fig, ax = viz.plot_feature_stability(df)
- coco_pipe.viz.decoding.plot_feature_scores(result, model=None, top_n=25, show_pvalues=True, ax=None, figsize=None)#
Plot univariate feature-selector scores.
- Parameters:
result (Any) – Experiment result with
get_feature_scores()or a feature-score DataFrame containingFeatureNameandScore.model (str | None) – Optional model name used to filter feature scores.
top_n (int | None) – Optional positive number of highest-scoring features to display.
show_pvalues (bool) – If True, annotate bars with
CorrectedPValuewhen available, otherwisePValue.ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
coco_pipe.viz.interactive.decoding.plot_feature_scoresInteractive Plotly version.
plot_feature_importanceRanked feature importances.
plot_feature_stabilityFeature-selection stability across folds.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> df = pd.DataFrame( ... { ... "Model": ["SVM"] * 4, ... "FeatureName": ["f1", "f2", "f3", "f4"], ... "Score": [12.3, 8.1, 5.4, 2.0], ... } ... ) >>> fig, ax = viz.plot_feature_scores(df)
- coco_pipe.viz.decoding.plot_decoding_topomap(sensor_df, value, info=None, coords=None, center=None, minimum_half_range=0.02, times=None, mask=None, title=None, ax=None, figsize=None)#
Plot a topomap from sensor-level decoding values.
- Parameters:
sensor_df (pandas.DataFrame) – DataFrame containing
FeatureNameand the selected value column.FeatureNameentries must match the provided sensor layout.value (str) – Numeric column to aggregate and plot.
info – Optional MNE
Infoobject used to resolve sensor positions.coords – Optional coordinate table used to resolve sensor positions when
infois not provided.center (float | None) – Optional numeric center for diverging color limits. When provided,
vminandvmaxare computed symmetrically around this value.minimum_half_range (float) – Minimum distance from
centerto either color limit.times (list[float] | None) – Optional list of time values used to filter rows when
Timeexists.mask (numpy.ndarray | None) – Optional boolean mask applied after time filtering.
title (str | None) – Optional axes title. Defaults to the plotted value name.
ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
plot_sensor_feature_heatmapFeature-family importance summarized by sensor.
plot_sensor_feature_profileFeature importances for one sensor.
plot_feature_sensor_profileSensor topomap for one feature family.
Examples
>>> import numpy as np, pandas as pd >>> from coco_pipe.viz import decoding as viz >>> names = [f"EEG{i:03d}" for i in range(5)] >>> df = pd.DataFrame( ... {"FeatureName": names, "Importance": np.linspace(0.1, 0.9, 5)} ... ) >>> coords = pd.DataFrame( ... { ... "ch_name": names, ... "x": np.cos(np.linspace(0, 2 * np.pi, 5, endpoint=False)), ... "y": np.sin(np.linspace(0, 2 * np.pi, 5, endpoint=False)), ... } ... ) >>> fig, ax = viz.plot_decoding_topomap(df, "Importance", coords=coords)
- coco_pipe.viz.decoding.plot_sensor_feature_heatmap(result, feature_metadata, feature_group=None, sensor_order=None, agg='mean', ax=None, figsize=None)#
Plot feature-family importance summarized by sensor.
- Parameters:
result (Any) – Experiment result with
get_feature_importances()or a compatible feature-importance DataFrame.feature_metadata (pandas.DataFrame) – Explicit metadata with
FeatureName,Sensor, andFeatureFamilycolumns.feature_group (str | None) – Optional feature family value used to filter rows. The parameter name is retained for compatibility; it matches
FeatureFamilyvalues.sensor_order (list[str] | None) – Optional ordered list of sensors to display as columns.
agg (str) – Aggregation function passed to
pandas.pivot_table.ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
plot_decoding_topomapSensor topomap for a single score column.
plot_sensor_feature_profileFeature importances for one sensor.
plot_feature_sensor_profileSensor topomap for one feature family.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> feat_meta = pd.DataFrame( ... { ... "FeatureName": ["f1", "f2", "f3", "f4"], ... "Sensor": ["S1", "S1", "S2", "S2"], ... "FeatureFamily": ["band1", "band2", "band1", "band2"], ... } ... ) >>> importance = pd.DataFrame( ... {"FeatureName": ["f1", "f2", "f3", "f4"], "Mean": [0.5, 0.3, 0.4, 0.2]} ... ) >>> fig, ax = viz.plot_sensor_feature_heatmap(importance, feat_meta)
- coco_pipe.viz.decoding.plot_sensor_feature_profile(result, feature_metadata, sensor, model=None, ax=None, figsize=None)#
Plot feature importances for one sensor.
- Parameters:
result (Any) – Experiment result with
get_feature_importances()or a compatible feature-importance DataFrame.feature_metadata (pandas.DataFrame) – Explicit metadata with
FeatureNameandSensorcolumns.sensor (str) – Sensor name used to select features.
model (str | None) – Optional model name used to filter importances.
ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
plot_sensor_feature_heatmapFeature-family importance summarized by sensor.
plot_feature_sensor_profileSensor topomap for one feature family.
plot_feature_importanceRanked feature importances.
Examples
>>> import pandas as pd >>> from coco_pipe.viz import decoding as viz >>> feat_meta = pd.DataFrame( ... {"FeatureName": ["f1", "f2", "f3"], "Sensor": ["S1", "S1", "S1"]} ... ) >>> importance = pd.DataFrame( ... {"FeatureName": ["f1", "f2", "f3"], "Mean": [0.5, 0.3, 0.1]} ... ) >>> fig, ax = viz.plot_sensor_feature_profile(importance, feat_meta, sensor="S1")
- coco_pipe.viz.decoding.plot_feature_sensor_profile(result, feature_metadata, feature_family, info=None, coords=None, model=None, title=None, ax=None, figsize=None)#
Plot a sensor topomap for one feature family.
- Parameters:
result (Any) – Experiment result with
get_feature_importances()or a compatible feature-importance DataFrame.feature_metadata (pandas.DataFrame) – Explicit metadata with
FeatureName,Sensor, andFeatureFamilycolumns.feature_family (str) – Feature-family value to aggregate over sensors.
info – Optional MNE
Infoobject used to resolve sensor positions.coords – Optional coordinate table used to resolve sensor positions when
infois not provided.model (str | None) – Optional model name used to filter importances.
title (str | None) – Optional topomap title. Defaults to
"<feature_family> Sensor Profile".ax (matplotlib.pyplot.Axes | None) – Existing Matplotlib axes to draw into.
figsize (tuple[float, float] | None) – Figure size used when creating a new axes.
- Returns:
The created or reused figure and axes.
- Return type:
See also
plot_sensor_feature_heatmapFeature-family importance summarized by sensor.
plot_sensor_feature_profileFeature importances for one sensor.
plot_decoding_topomapSensor topomap for a single score column.
Examples
>>> import numpy as np, pandas as pd >>> from coco_pipe.viz import decoding as viz >>> feat_meta = pd.DataFrame( ... { ... "FeatureName": ["f1", "f2"], ... "Sensor": ["S1", "S2"], ... "FeatureFamily": ["band1", "band1"], ... } ... ) >>> importance = pd.DataFrame({"FeatureName": ["f1", "f2"], "Mean": [0.5, 0.3]}) >>> coords = pd.DataFrame( ... {"ch_name": ["S1", "S2"], "x": [0.1, -0.1], "y": [0.1, -0.1]} ... ) >>> fig, ax = viz.plot_feature_sensor_profile( ... importance, feat_meta, "band1", coords=coords ... )
- coco_pipe.viz.decoding.plot_head_to_head(frame, *, label, value, error=None, reference=None, title='Head-to-Head Comparison', ylabel=None, ax=None, figsize=None)#
Plot labelled estimates for cross-result head-to-head comparisons.
- coco_pipe.viz.decoding.plot_paired_delta(frame, *, label, delta, lower=None, upper=None, title='Paired Difference', xlabel='Comparison', ylabel='Delta', ax=None, figsize=None)#
Plot paired deltas with optional confidence intervals.