coco_pipe.report.Report#
- class coco_pipe.report.Report(title='CoCo Analysis Report', config=None, theme='paper', asset_urls=None)#
Bases:
ContainerElementThe main report container.
- Parameters:
title (str) – The report title.
config (Union[Dict, ReportConfig], optional) – Configuration dictionary or ReportConfig object used for the run.
asset_urls (dict or
"inline", optional) –Controls how the Plotly / Tailwind / pako JS bundles are loaded:
None(default): load from CDN.dict: override one or more URLs (e.g. point at self-hosted copies)."inline": download (and cache on disk) the bundles, then inline them in<script>tags so the rendered HTML is fully self-contained and openable offline. Seecoco_pipe.report._assets.
theme (str)
- add_section(section)#
Syntactic sugar for adding a Section.
- add_figure(fig, caption=None)#
Add a figure (Matplotlib) or Image.
- add_container(container, name='Data Overview', show_coords=True, show_dist=True)#
Add a summary section for a DataContainer. Automatically runs quality checks (Missingness, Constants).
- Parameters:
container (DataContainer) – The data container to summarize.
name (str) – Title for the section.
show_coords (bool) – If True, shows the table of coordinates.
show_dist (bool) – If True, shows the data/class distribution plot.
- Return type:
- add_raw_preview(data, name='Raw Data Inspector')#
Add an interactive scroller for raw data. Automatically checks for flatlines and outliers.
- Parameters:
data (DataContainer or np.ndarray) – The data to visualize.
name (str) – Section title.
- Return type:
- render()#
Render the full HTML report.
Walks every element to collect heavy payload data (Plotly figures, interactive tables) into a single registry keyed by UUID, then compresses and base64-encodes the registry so it can be embedded inline in the page.
Payload format (the contract with
base.html)#Each element that wants to store payload assigns itself a UUID
data-idand pushes its data into the registry:registry[uuid] = {<element-specific JSON>}
The registry is then serialized as:
JSON.dumps(registry) -> utf-8 bytes -> gzip.compress() -> base64.b64encode().decode("utf-8")
and emitted inside
<script type="application/json" id="report-payload">...</script>. The browser script inbase.htmlreverses this (atob -> pako.inflate -> JSON.parse) and exposes the result asREPORT_DATA. Each<div class="lazy-plot" data-id="..."></div>then looks up its payload inREPORT_DATA[dataId]on intersection.- Return type:
- add_summary_card(metrics, colors=None)#
Add a row of KPI stat-cards above the first section.
Each key-value pair in metrics becomes one
StatCardElement. The card row is inserted at the top of the report children list so it appears before any sections regardless of when this method is called.- Parameters:
- Returns:
The report instance for fluent chaining.
- Return type:
Examples
>>> report.add_summary_card({"Best Accuracy": 0.842, "Models": 3, "Folds": 5})
- show(port=None)#
Render the report and open it in the default web browser.
A temporary HTML file is written to the system temp directory, then
webbrowser.openis called. No server is started; the file is self-contained and can be opened directly.- Parameters:
port (int, optional) – Ignored. Kept for API compatibility with future server-based
show()variants.- Return type:
None
Examples
>>> report.show()
- save(filename)#
Render and save the report to a file.
- Parameters:
filename (str or Path) – Path to save the HTML file.
- Return type:
None
Notes
Emits a
UserWarningwhen the report still depends on three external CDN scripts (Plotly, Tailwind, pako). A CDN-backed report renders as grey placeholders if opened without a network connection (e.g.file://viewing, offline archives, restrictive corporate firewalls, air-gapped machines). Passasset_urls="inline"toReportto bundle the JavaScript directly into the HTML.
- add_comparison(metrics_df, name='Method Comparison')#
Add a comparison section for multiple reduction methods to self.
- Parameters:
- Returns:
self with the new section appended.
- Return type:
- Raises:
ValueError – If no comparison metrics are available after normalization.
- add_decoding_diagnostics(result, metric=None, model=None, name='Decoding Diagnostics')#
- add_decoding_features(result, *, feature_metadata=None, name='Features')#
- add_decoding_neural_artifacts(result, model=None, name='Neural Artifacts')#
- add_decoding_overview(result, *, name='Overview')#
- add_decoding_performance(result, *, metric=None, name='Performance')#
- add_decoding_statistical_assessment(result, metric=None, model=None, name='Statistical Assessment')#
- add_decoding_summary(result, name='Decoding Summary')#
- add_decoding_temporal(result, metric=None, model=None, name='Temporal Decoding')#
- add_decoding_topomaps(result, *, feature_metadata=None, info=None, coords=None, name='Sensor Maps')#
- add_element(element)#
Add a child element.
- add_reduction(reducer, name=None, *, X_emb=None, labels=None, metadata=None, times=None)#
Add one scored and optionally interpreted reduction result to self.
- Parameters:
self (Report) – Target report.
reducer (Any) – Reduction object implementing
get_summary().name (str, optional) – Section title. Defaults to the reduction method name.
X_emb (np.ndarray, optional) – Explicit embedding to visualize. When omitted, the section renders scalar summaries, diagnostics, and interpretation outputs only.
labels (np.ndarray, optional) – Optional labels aligned with
X_embfor embedding or trajectory plots.metadata (dict, optional) – Optional column-oriented metadata aligned with the sample axis of a 2D embedding.
times (np.ndarray, optional) – Optional explicit time axis aligned with the time dimension of a 3D trajectory tensor.
- Returns:
self with the new section appended.
- Return type:
- Raises:
ValueError – If
X_embis provided with an unsupported number of dimensions.
See also
coco_pipe.dim_reduction.core.DimReduction.get_summary,coco_pipe.viz.interactive.dim_reduction.plot_embedding,coco_pipe.viz.interactive.dim_reduction.plot_trajectory
- add_reduction_components(components, *, feature_names=None, name='Component Loadings')#
Add a component-loadings heatmap to self.
- Parameters:
- Returns:
self with the new section appended, or unchanged if components is
None.- Return type:
Examples
>>> report.add_reduction_components(pca.components_, feature_names=ch_names)
- add_reduction_coranking(coranking_matrix, *, max_k=None, name='Co-Ranking Matrix')#
Add a co-ranking-matrix heatmap to self.
- Parameters:
- Returns:
self with the new section appended, or unchanged if coranking_matrix is
None.- Return type:
Examples
>>> report.add_reduction_coranking(diagnostics["coranking_matrix_"])
- add_reduction_diagnostics(X_orig, X_emb, *, name='Diagnostics')#
Add a Shepard diagram comparing original and embedded distances to self.
- Parameters:
- Returns:
self with the new section appended, or unchanged if either array is
None.- Return type:
Examples
>>> report.add_reduction_diagnostics(X_orig, X_2d)
- add_reduction_embedding(X_emb, *, labels=None, metadata=None, name='Embedding')#
Add a scatter plot of the low-dimensional embedding to self.
- Parameters:
- Returns:
self with the new section appended, or unchanged if X_emb is
None.- Return type:
Examples
>>> report.add_reduction_embedding(X_2d, labels=y)
- add_reduction_interpretation(interpretation, *, analysis='loadings', name='Interpretation')#
Add a component-interpretation plot to self.
- Parameters:
- Returns:
self with the new section appended, or unchanged if interpretation is falsy.
- Return type:
Examples
>>> report.add_reduction_interpretation(result.get_summary()["interpretation"])
- add_reduction_metrics(reduction, *, metric=None, name='Quality Metrics')#
Add a quality-metrics table and bar chart to self.
- Parameters:
- Returns:
self with the new section appended, or unchanged if no scores are available.
- Return type:
Examples
>>> report.add_reduction_metrics(pca_result)
- add_reduction_overview(reduction, *, name='Overview')#
Add a reduction-summary table to self.
- Parameters:
- Returns:
self with the new section appended, or unchanged if the summary is empty.
- Return type:
See also
make_reduction_reportFactory that calls this and all other adders.
Examples
>>> report = Report(title="My Report") >>> report.add_reduction_overview(pca_result)
- add_reduction_trajectory(X, *, times=None, labels=None, name='Trajectory')#
Add a temporal trajectory plot to self.
- Parameters:
- Returns:
self with the new section appended, or unchanged if X is
None.- Return type:
Examples
>>> report.add_reduction_trajectory(X_3d, times=times, labels=y)
- add_reduction_trajectory_separation(separation, *, times=None, top_n=None, name='Trajectory Separation')#
Add a trajectory-separation line chart to self.
- Parameters:
- Returns:
self with the new section appended, or unchanged if separation is empty.
- Return type:
Examples
>>> report.add_reduction_trajectory_separation(sep, times=times, top_n=5)
- collect_payload(registry)#
Recursively collect payload from children.