pelinker.reporting¶
AllScreenerCvResult
dataclass
¶
Unified stratified CV: embedding screener (LDA vs SVM), manifold OOV, and stacked score.
Source code in pelinker/reporting.py
BinaryClassifierMetrics
dataclass
¶
Precision / recall / F1 / AUC vs negative class (label 1); spread is fold-wise.
Source code in pelinker/reporting.py
ClusteringFitMetrics
dataclass
¶
Fit-time clustering diagnostics at a fixed min_cluster_size.
Source code in pelinker/reporting.py
dbcv
instance-attribute
¶
HDBSCAN relative_validity_ when available.
ClusteringHyperparameters
dataclass
¶
HDBSCAN (and related) choices selected by the grid search / smoother.
Add fields here as more knobs participate in optimization; call sites then stay typed.
Source code in pelinker/reporting.py
ClusteringSearchSummaryRow
dataclass
¶
One row of the model×layer clustering search table (singleton or fusion label).
Use :meth:to_flat_dict for CSV / pandas / heatmaps (legacy column names).
Source code in pelinker/reporting.py
to_flat_dict()
¶
Keys aligned with grid CSV / checkpoint / plot_heatmap expectations.
Source code in pelinker/reporting.py
HyperparameterSearchStats
dataclass
¶
Distribution of chosen hyperparameters across repeated clustering samples.
Source code in pelinker/reporting.py
LinkerFitDiagnostics
dataclass
¶
Per-row training diagnostics for plotting (often stratified-subsampled).
Source code in pelinker/reporting.py
n_total
instance-attribute
¶
Original mention count before subsampling (same as len(prepared) at fit time).
oov_label
instance-attribute
¶
1 iff entity == negative_label (same convention as :class:ModelSelectionReport).
sample_random_state
instance-attribute
¶
RNG seed used for stratified subsampling (or configured seed when no subsample).
MeanWithUncertainty
dataclass
¶
Sample mean and standard deviation (ddof=1) over repeated runs; std=0 for a single run.
Source code in pelinker/reporting.py
MetricMeanStd
dataclass
¶
ModelSelectionReport
dataclass
¶
Report containing clustering analysis results for one sample.
Source code in pelinker/reporting.py
all_screener_cv = None
class-attribute
instance-attribute
¶
Unified stratified CV for embedding screener, manifold OOV, and stacked score.
best_score
instance-attribute
¶
DBCV (relative_validity_) at the chosen min_cluster_size (mean when from aggregate).
mention_quality = None
class-attribute
instance-attribute
¶
All mentions (pos+neg) with PCA quality scores and oov_label; cluster=-1 for negatives.
n_clusters_emergent
instance-attribute
¶
HDBSCAN emergent cluster count at :attr:hyperparameters min_cluster_size.
In model-selection this is the grid-optimal best_size, not an arbitrary MCS.
To compare with Linker.fit at a fixed MCS, use
:func:n_clusters_at_min_cluster_size on :attr:metrics_df instead.
number_properties
instance-attribute
¶
Count of distinct KB entity labels in the frame used for PCA→UMAP (excludes pelinker.onto.NEGATIVE_LABEL when screening).
oov_label
instance-attribute
¶
Per-row OOV mask: 1 iff entity == negative_label (same length as pca_residuals).
screener_oos_datapoints = None
class-attribute
instance-attribute
¶
Per-datapoint OOS scores (not serialized in JSON clustering report).
training_diagnostics = None
class-attribute
instance-attribute
¶
Stratified-subsampled PCA quality + screener / manifold OOV scores (linker fit only).
ModelSelectionRunReport
dataclass
¶
Standardized aggregate report for one model-selection run.
Source code in pelinker/reporting.py
NegativeScreenerInSampleMetrics
dataclass
¶
Train-set precision / recall / F1 for detecting negative_label (binary label 1).
Source code in pelinker/reporting.py
PerDatapointScores
dataclass
¶
Out-of-sample scores per stratified-fold test datapoint.
Source code in pelinker/reporting.py
clustering_report_to_jsonable_dict(report)
¶
Flatten a :class:ClusteringReport into JSON-serializable built-ins (no DataFrames/ndarrays).
Intended for json.dumps or for pickling a stable, language-adjacent blob. Schema version
is stored under "schema" for forward compatibility.
Source code in pelinker/reporting.py
clustering_search_summary_row_from_flat_dict(row)
¶
Reconstruct :class:ClusteringSearchSummaryRow from :meth:to_flat_dict output.
Source code in pelinker/reporting.py
entity_negative_label_mask_01(entities, negative_label)
¶
Per-row binary labels aligned with entities: 1 if the row's entity equals
negative_label (same convention as the negative screener positive class), else 0.
Source code in pelinker/reporting.py
linker_fit_cluster_composition_path(report_dir)
¶
Filesystem path for the entity-weighted cluster composition artifact.
Source code in pelinker/reporting.py
linker_fit_cluster_kb_path(report_dir)
¶
Filesystem path for the cluster-derived KB labels-map JSON under report_dir.
linker_fit_clustering_report_path(report_dir)
¶
Filesystem path for the fit-time :class:ClusteringReport JSON under report_dir.
Source code in pelinker/reporting.py
linker_fit_emergent_clusters_path(report_dir)
¶
Filesystem path for the emergent-cluster catalog JSON under report_dir.
Source code in pelinker/reporting.py
mention_quality_frame(dfr, *, neg_mask, cluster_kb, pca_residuals, pca_mahalanobis, pca_spectral_entropy, negative_label)
¶
Per-mention PCA quality and labels for all rows (KB clustered; negatives cluster=-1).
Source code in pelinker/reporting.py
model_selection_run_report_path(report_dir)
¶
Filesystem path for the standardized model-selection aggregate report.
model_selection_summary_json_path(report_dir)
¶
Top-level replot summary (rankings, best combos) as plain JSON.
n_clusters_at_min_cluster_size(metrics_df, min_cluster_size)
¶
n_clusters from a grid metrics_df row at min_cluster_size (for fit parity).
Source code in pelinker/reporting.py
read_cluster_composition_json(path)
¶
Load a composition table and metadata written by :func:write_cluster_composition_json.
Source code in pelinker/reporting.py
read_clustering_report_json(path)
¶
Load a :class:ModelSelectionReport written by :func:write_clustering_report_json.
Supports schema pelinker.clustering_report.v10 (cluster-space viz coords).
Source code in pelinker/reporting.py
read_emergent_clusters_json(path)
¶
Load emergent-cluster catalog JSON.
Source code in pelinker/reporting.py
subsample_diagnostics_stratified(full, *, max_rows, random_state)
¶
Stratified subsample by oov_label (preserve class proportions, at least one row per
non-empty class when two classes exist). Mirrors logic used in pairgrid plotting.
Source code in pelinker/reporting.py
summarize_clustering_reports_for_search(reports, *, model, layer, pooled_min_cluster_size=None)
¶
Aggregate repeated :class:ClusteringReport runs into one search summary row.
When pooled_min_cluster_size is set (after aggregating grid curves across samples),
best_size / best_size_std report that single consensus hyperparameter (std is 0)
and dbcv is the mean (and std) of each sample's DBCV at that grid point.
n_clusters_emergent remains the mean of per-sample fits at each sample's grid-optimal
size; use :func:n_clusters_at_min_cluster_size on pooled grid CSV rows for a fixed MCS.
Otherwise (independent runs or legacy callers) best_size is the mean of per-report
chosen sizes and dbcv is the mean of each report's best_score.
Raises:
| Type | Description |
|---|---|
ValueError
|
if |
Source code in pelinker/reporting.py
939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 | |
write_cluster_composition_json(path, composition_df, *, top_n=3, weighting='inv_sqrt_mention_count', summary=None, max_clusters_in_rows=None, indent=2)
¶
Serialize a processed cluster-composition table written at fit time.
Source code in pelinker/reporting.py
write_cluster_derived_labels_map_json(path, labels_map, *, indent=2)
¶
Write a cluster-derived labels map (entity_id → cluster_name) to a plain JSON file.
The file is human-readable and can be passed directly to a subsequent fit as a new KB
labels_map. Parent directories are created when missing.
Source code in pelinker/reporting.py
write_clustering_report_json(path, report, *, indent=2)
¶
Serialize report with :func:clustering_report_to_jsonable_dict to UTF-8 JSON.
Parent directories are created when missing.
Source code in pelinker/reporting.py
write_emergent_clusters_json(path, payload, *, indent=2)
¶
Write :func:~pelinker.cluster_composition_viz.build_emergent_clusters_catalog output.