k4bench.analysis.event_drivers¶
k4bench.analysis.event_drivers ¶
What an event's cost goes with: per-event costs set against what each event holds.
An event's cost (its time, an algorithm's time, instructions or allocations,
the time and steps simulation spent in a detector) is a :class:Measure, one
value per event. What the event holds is its row of an :class:EventTable:
the canned quantities of :data:FEATURES, computed from its generator
particles (:mod:k4bench.analysis.event_source), and what each collection
holds in it (:mod:k4bench.analysis.event_size), one column each under a name
an expression (:mod:k4bench.analysis.expression) can use:
n_<collection>,E_<collection>: the elements and calorimeter energy of the event itself, as the job read it: simulation's output, or reconstruction's input;out_n_<collection>,out_E_<collection>: reconstruction's outputs.
A name that would collide with another gets its file's name appended, then a
number; :attr:Column.collection and :attr:Column.file say what it is.
Matching events
A table's rows are the entries of the files it was read from; a measure's
values are keyed by the event number the job's profiling counted. The two
match when the profiling counted exactly the entries 0 .. n-1, which is
what :func:align checks; when they do not (a filtered output, an event range
not from the start), it says so and nothing is matched. The files' rows are
matched entry by entry: :func:event_table refuses files whose EventHeaders
name different events at the same entry (a reordered output), as far as they
have EventHeaders. The warm-up event 0 is left out of every measure, as in the
other per-event views.
What the numbers do and do not say
:func:associations ranks the columns by Spearman's rank correlation with a
measure, so a cost that rises with a quantity in any monotonic way ranks high
and one with a symmetric or periodic dependence (on phi, or on theta
for a forward-backward symmetric cost) ranks low; the latter take a scatter,
or abs_cos_theta. The top of a ranking picked from dozens of columns is
an association to look at, not a significance: no threshold is drawn.
:func:trend fits one straight line, robustly, and the events well above it
are above that line, not necessarily expensive for their content as a whole.
Feature
dataclass
¶
A canned per-event quantity of the generator particles.
Column
dataclass
¶
Column(label: str, kind: str, ranked: bool = True, collection: str | None = None, file: str | None = None, expression: str | None = None)
One column of an :class:EventTable.
EventTable
dataclass
¶
EventTable(frame: DataFrame, columns: Mapping[str, Column], source: EventSource | None = None, left_out: Mapping[str, str] = dict(), _particles: dict = dict())
What each event holds: one row per entry, one column per quantity.
evaluate ¶
expression in each event (:func:k4bench.analysis.expression.evaluate).
Source code in k4bench/analysis/event_drivers.py
Measure
dataclass
¶
One per-event cost of one configuration.
Trend
dataclass
¶
A straight line through a measure against one quantity: Theil–Sen's slope, and the median intercept.
event_table ¶
event_table(source: EventSource | None, content: Sequence[OutputFile] = (), outputs: Sequence[OutputFile] = ()) -> EventTable | None
The table of a run's events: :data:FEATURES from source, and each
collection's elements and energy from content (simulation's output
file) or the source's input content, and from outputs
(reconstruction's files), each measured file for as many events as the
others; None when there is nothing to tabulate.
Each output is checked against source on its own and left out, with
why (:attr:EventTable.left_out), when it holds other events: another
number of them, other EventHeaders, or an entry without one, its or the
input's, which leaves its order unchecked.
Raises ValueError for outputs without source, since only the
input's EventHeaders show that the outputs hold the events in the order
the job read them, and when the source and content disagree on the
number of events or their EventHeaders on which event an entry is.
Source code in k4bench/analysis/event_drivers.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
alias ¶
The expression name of collection of file under prefix: its
name with every character that cannot be in a name made _, then, if
that is taken, the file's name appended, then a number.
Source code in k4bench/analysis/event_drivers.py
simulation_measures ¶
simulation_measures(event_data: DataFrame | None, regions: Mapping | None) -> list[Measure]
The per-event costs of one simulation configuration: its event time
(event_data, :func:~k4bench.analysis.loader.load_event_timing's frame)
and the time and steps spent in each detector (regions, its
:func:~k4bench.analysis.loader.load_region_timing entry), the
costliest detectors of each first.
Source code in k4bench/analysis/event_drivers.py
reconstruction_measures ¶
reconstruction_measures(event_data: DataFrame | None, timing: ComponentTiming | None) -> list[Measure]
The per-event costs of one reconstruction configuration: its event
time (event_data) and, per algorithm, each of
:data:MEASURE_METRICS its auditor file (timing) recorded, the
costliest algorithms of each first.
Source code in k4bench/analysis/event_drivers.py
align ¶
align(measure: Measure, table: EventTable) -> str | None
Why measure's events cannot be matched to table's rows, or
None when they can: the job's profiling must have counted exactly
the entries 0 .. n-1 of the table's files.
Source code in k4bench/analysis/event_drivers.py
paired ¶
paired(measure: Measure, x: Series) -> DataFrame
measure's events beside x (a table column, indexed by entry), the
events either lacks dropped: event, x and y.
Source code in k4bench/analysis/event_drivers.py
spearman ¶
Spearman's rank correlation of x and y over the events both have,
or None with fewer than :data:MIN_PAIRS of them or either constant.
Source code in k4bench/analysis/event_drivers.py
associations ¶
associations(measure: Measure, table: EventTable, columns: Sequence[str] | None = None) -> DataFrame
Every ranked column of table (or columns) by the size of its rank
correlation with measure, largest first: rho with its sign, and
n, the events paired. Columns without a correlation (constant,
too few events) are left out.
The columns with a value in every event of measure are ranked and
correlated together; each of the others over the events it has
(:func:spearman).
Source code in k4bench/analysis/event_drivers.py
trend ¶
trend(x: Series, y: Series) -> Trend | None
The robust line of y against x; None with fewer than
:data:MIN_SLOPE_EVENTS events or no two distinct x.
Source code in k4bench/analysis/event_drivers.py
above_trend ¶
above_trend(pairs: DataFrame, line: Trend) -> DataFrame
The events of pairs (:func:paired) more than
:data:OUTLIER_SIGMAS robust standard deviations above line, furthest
first: x, y, expected, residual and ratio (NaN where
the line is too near zero, :data:MIN_RATIO_SHARE). When most events lie
exactly on the line, as a count that rarely changes does, every event
above it beyond rounding (:data:_ON_LINE).
Source code in k4bench/analysis/event_drivers.py
association_matrix ¶
association_matrix(measures: Sequence[Measure], table: EventTable, *, rows: int = 15, columns: int = 12, per_row: int = 5) -> tuple[DataFrame, DataFrame, dict[str, list[str]]]
The rank correlations of the first rows of measures that match
table with the columns most associated with them: the per_row
strongest of each, the strongest overall first, at most columns of
them, a column that moves with one already chosen (:data:SIMILAR_RHO)
folded into it. (rho, n, similar): the first two indexed by measure
name with one column per table column, NaN where a pair has no
correlation; the last, each chosen column's folded ones.