|
| 1 | +Analysis configuration |
| 2 | +====================== |
| 3 | + |
| 4 | +The analysis workflow reads saved predictions from :doc:`inference`. |
| 5 | +It selects samples, computes per-sample values, reduces them to summaries, and writes reports and figures. |
| 6 | +The pipeline is independent of model training and inference. |
| 7 | + |
| 8 | +An analysis configuration requires five lists: |
| 9 | + |
| 10 | +* ``selectors`` choose samples or sample groups. |
| 11 | +* ``collectors`` compute values for each selected sample. |
| 12 | +* ``aggregators`` reduce collected values to summaries. |
| 13 | +* ``reporters`` write structured results. |
| 14 | +* ``plotters`` write figures and table outputs. |
| 15 | + |
| 16 | +Analysis pipeline |
| 17 | +----------------- |
| 18 | + |
| 19 | +Analysis starts with one prediction reader for each inference run. |
| 20 | +The readers provide prediction records and, when the inference datasource can be loaded, matching structures. |
| 21 | + |
| 22 | +1. Selectors create the sample streams to analyse. Each configured selector is applied independently to each prediction reader. |
| 23 | + Use a ``chain`` selector when several filters must be applied in sequence. |
| 24 | +2. Collectors process every sample in each selected stream. Their per-sample values are written to JSONL files under the analysis run's ``aux/`` directory. |
| 25 | +3. Aggregators read the selector streams and collector values and reduce them to summary results such as errors, distributions, rankings, or per-channel statistics. |
| 26 | +4. Reporters and plotters consume the combined analysis results. Reporters write structured files, while plotters create figures and tables. |
| 27 | + |
| 28 | +With this pipeline it is easily possible to analyze and compare multiple inference runs. |
| 29 | + |
| 30 | +Available implementations |
| 31 | +-------------------------- |
| 32 | + |
| 33 | +Selectors |
| 34 | +~~~~~~~~~ |
| 35 | + |
| 36 | +* ``all`` and ``none`` (:class:`~xanesnet.analysis.selectors.identity.IdentitySelector`) keep all samples. |
| 37 | +* ``index_list`` (:class:`~xanesnet.analysis.selectors.by_index.IndexSelector`) selects explicit zero-based indices. |
| 38 | +* ``index_range`` (:class:`~xanesnet.analysis.selectors.by_range.IndexRangeSelector`) selects an inclusive ``start`` to exclusive ``end`` range. |
| 39 | +* ``random`` (:class:`~xanesnet.analysis.selectors.bernoulli.BernoulliSelector`) keeps samples with probability ``p``. |
| 40 | +* ``element`` (:class:`~xanesnet.analysis.selectors.by_element.ElementSelector`) selects target sites by chemical element. |
| 41 | +* ``structure_cluster`` (:class:`~xanesnet.analysis.selectors.structure_cluster.StructureClusterSelector`) partitions structures using a descriptor. |
| 42 | +* ``chain`` (:class:`~xanesnet.analysis.selectors.chain.ChainSelector`) applies an ordered sequence of selectors. |
| 43 | + |
| 44 | +Collectors |
| 45 | +~~~~~~~~~~ |
| 46 | + |
| 47 | +* ``loss`` (:class:`~xanesnet.analysis.collectors.loss.LossCollector`) computes a configured loss for each sample and can collect an energy-resolved vector. |
| 48 | +* ``descriptor`` (:class:`~xanesnet.analysis.collectors.descriptor.DescriptorCollector`) computes a descriptor for each matched structure. |
| 49 | + |
| 50 | +Aggregators |
| 51 | +~~~~~~~~~~~ |
| 52 | + |
| 53 | +* ``scalar`` (:class:`~xanesnet.analysis.aggregators.scalar.ScalarAggregator`) computes scalar summary statistics. |
| 54 | +* ``vector`` (:class:`~xanesnet.analysis.aggregators.vector.VectorAggregator`) summarises vector values such as energy-resolved losses. |
| 55 | +* ``spectrum`` (:class:`~xanesnet.analysis.aggregators.spectrum.SpectrumAggregator`) computes per-channel prediction and target statistics. |
| 56 | +* ``ranking`` (:class:`~xanesnet.analysis.aggregators.ranking.RankingAggregator`) selects best and worst samples using a collected value. |
| 57 | +* ``bias_variance`` (:class:`~xanesnet.analysis.aggregators.bias_variance.BiasVarianceAggregator`) computes a per-channel bias and variance decomposition. |
| 58 | + |
| 59 | +Reporters |
| 60 | +~~~~~~~~~ |
| 61 | + |
| 62 | +* ``scalar`` (:class:`~xanesnet.analysis.reporters.scalar.ScalarReporter`) writes per-sample scalar values as CSV files. |
| 63 | +* ``statistics`` (:class:`~xanesnet.analysis.reporters.statistics.StatisticsReporter`) writes aggregated values as YAML or JSON. |
| 64 | + |
| 65 | +Plotters |
| 66 | +~~~~~~~~ |
| 67 | + |
| 68 | +* ``scalar`` (:class:`~xanesnet.analysis.plotters.scalar.ScalarPlotter`) plots scalar-value distributions. |
| 69 | +* ``spectra_all`` (:class:`~xanesnet.analysis.plotters.spectra.AllSpectraPlotter`) plots selected prediction and target spectra. |
| 70 | +* ``spectra_comparison`` (:class:`~xanesnet.analysis.plotters.spectra_comparison.SpectraComparisonPlotter`) compares best and worst samples using ``sort_key``. |
| 71 | +* ``stat_table`` (:class:`~xanesnet.analysis.plotters.stat_table.StatTablePlotter`) writes PDF tables of aggregated statistics. |
| 72 | +* ``stat_table_latex`` (:class:`~xanesnet.analysis.plotters.stat_table_latex.StatTableLatexPlotter`) writes LaTeX sources and optional PDFs. |
| 73 | +* ``energy_resolved_loss`` (:class:`~xanesnet.analysis.plotters.energy_resolved.EnergyResolvedLossPlotter`) plots energy-resolved loss curves. |
| 74 | +* ``mean_spectrum`` (:class:`~xanesnet.analysis.plotters.mean_spectrum.MeanSpectrumPlotter`) plots mean spectra and best or worst tail means. |
| 75 | +* ``parity`` (:class:`~xanesnet.analysis.plotters.parity.ParityPlotter`) plots predicted-versus-target intensity parity. |
| 76 | +* ``bias_variance`` (:class:`~xanesnet.analysis.plotters.bias_variance.BiasVariancePlotter`) plots per-channel bias and variance. |
| 77 | +* ``error_correlation`` (:class:`~xanesnet.analysis.plotters.error_correlation.ErrorCorrelationPlotter`) plots pairwise error correlations using ``sort_key``. |
| 78 | +* ``pca`` (:class:`~xanesnet.analysis.plotters.pca.PcaPlotter`) plots structure groups in descriptor PCA space. |
| 79 | +* ``selector_overview`` (:class:`~xanesnet.analysis.plotters.selector_overview.SelectorOverviewPlotter`) compares selector groups using ``err_key``. |
| 80 | + |
| 81 | +Common configuration |
| 82 | +-------------------- |
| 83 | + |
| 84 | +The optional top-level fields are ``seed`` and ``preload``. |
| 85 | +``preload`` loads prediction records and matched structures during setup instead of reading them on demand. |
| 86 | +This can speed up analysis significantly for small test datasets. |
| 87 | + |
| 88 | +Examples |
| 89 | +-------- |
| 90 | + |
| 91 | +Independent selector streams: |
| 92 | + |
| 93 | +.. code-block:: yaml |
| 94 | +
|
| 95 | + selectors: |
| 96 | + - selector_type: element |
| 97 | + elements: [Fe] |
| 98 | + - selector_type: random |
| 99 | + p: 0.1 |
| 100 | +
|
| 101 | +Sequential filtering: |
| 102 | + |
| 103 | +.. code-block:: yaml |
| 104 | +
|
| 105 | + selectors: |
| 106 | + - selector_type: chain |
| 107 | + chain: |
| 108 | + - selector_type: element |
| 109 | + elements: [Fe] |
| 110 | + - selector_type: random |
| 111 | + p: 0.1 |
| 112 | +
|
| 113 | +A complete combination of analysis components is shown in ``configs/analyze_example.yaml``. |
| 114 | + |
| 115 | +API reference |
| 116 | +------------- |
| 117 | + |
| 118 | +See also :mod:`xanesnet.analysis` and the schemas under ``xanesnet/schemas/analysis/`` for complete fields and defaults. |
0 commit comments