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
n_rows_realized = None
class-attribute
instance-attribute
¶
Mean (and std) realized mention-row count across this combination's draws.
best_size is only interpretable against this scale; carrying it here is what lets
:mod:pelinker.scaling fit min_cluster_size*(N) across runs.
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).
distillation_fidelity = None
class-attribute
instance-attribute
¶
Held-out agreement between the compact entity head and its HDBSCAN teacher.
None for legacy fits (no student) and when the holdout was disabled or skipped.
mention_quality = None
class-attribute
instance-attribute
¶
All mentions (pos+neg) with PCA quality scores and oov_label; cluster=-1 for negatives.
min_cluster_size_provenance = None
class-attribute
instance-attribute
¶
Where :attr:hyperparameters min_cluster_size came from (linker fit only).
Explicit, extrapolated from a scale curve, or the bare default — recorded so a fitted model never carries an unexplained hyperparameter.
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.
n_rows_realized = None
class-attribute
instance-attribute
¶
Mention rows this draw actually clustered on.
The realized N, not the clustering_sample_rows cap: when the frame is smaller
than the cap, or the cap is unset, the two differ. Sample-size-dependent
hyperparameters (min_cluster_size, and through it HDBSCAN min_samples) are
only interpretable against this number — see :mod:pelinker.scaling.
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_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_kb_out_path(report_dir)
¶
Filesystem path for the KB-out catalog JSON under report_dir.
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_kb_out_json(path)
¶
Load KB-out 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
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 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 | |
write_cluster_composition_json(path, composition_df, *, top_n=3, weighting='inv_sqrt_mention_count', exclude_noise=False, 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_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_kb_out_json(path, payload, *, indent=2)
¶
Write :func:~pelinker.kb_out.build_kb_out_catalog output.