Domain regression data preparation functions.
Provides functions to prepare regression model data for table and chart rendering, including model fit data, log-log analysis, and an orchestration function for rendering regression views.
Domain regression data preparation functions. Provides functions to prepare regression model data for table and chart rendering, including model fit data, log-log analysis, and an orchestration function for rendering regression views.
(format-log-log-slope slope)Format log-log slope as complexity class estimate. Returns string like 'O(n^1.02)' or 'O(n)' for integer slopes.
Format log-log slope as complexity class estimate. Returns string like 'O(n^1.02)' or 'O(n)' for integer slopes.
(prepare-log-log-fit-line log-log-data {:keys [_axis _impl-axis]})Generate fit line points for log-log plot. Returns vector of point maps with x, y, and optionally impl key.
Uses the pre-computed slope and intercept: y = slope * x + intercept where x = log(n), y = log(metric).
Generate fit line points for log-log plot. Returns vector of point maps with x, y, and optionally impl key. Uses the pre-computed slope and intercept: y = slope * x + intercept where x = log(n), y = log(metric).
(prepare-log-log-points log-log-data {:keys [axis _impl-axis]})Prepare log-log transformed data points for scatter plot. Returns {:points [...] :axis-name string} or nil.
Points have keys: x (log(n)), y (log(metric)), and optionally yLower, yUpper for log-transformed error bounds. For multi-impl mode, points also have :impl key.
The log-log-data comes from the :regressions map of a :criterium/domain-log-log-regression result.
Prepare log-log transformed data points for scatter plot.
Returns {:points [...] :axis-name string} or nil.
Points have keys: x (log(n)), y (log(metric)), and optionally
yLower, yUpper for log-transformed error bounds.
For multi-impl mode, points also have :impl key.
The log-log-data comes from the :regressions map of a
:criterium/domain-log-log-regression result.(prepare-log-log-residuals log-log-data {:keys [_axis _impl-axis]})Compute residual points for log-log plot. Returns vector of point maps with x (log(n)), residual, and optionally impl.
Residuals are in log space: residual = log(y) - (slope * log(x) + intercept)
Compute residual points for log-log plot. Returns vector of point maps with x (log(n)), residual, and optionally impl. Residuals are in log space: residual = log(y) - (slope * log(x) + intercept)
(prepare-regression-fit-lines {:keys [x-vals total-scale]}
{:keys [models by-impl impl-keys]})Generate fit line points for plotting. For single-impl mode, models is a seq of model maps. For multi-impl mode, by-impl is a map of impl-key -> {:models [...] :best-fit id}. Returns vector of point maps with x, y, and model or impl key.
Generate fit line points for plotting.
For single-impl mode, models is a seq of model maps.
For multi-impl mode, by-impl is a map of impl-key ->
{:models [...] :best-fit id}.
Returns vector of point maps with x, y, and model or impl key.(prepare-regression-model-table
{:keys [models best-fit]}
{:keys [best-fit-marker plotted-marker tolerance]
:or {best-fit-marker "✓" plotted-marker "" tolerance 0.01}})Prepare model table rows for single-impl regression display. Returns vector of row maps with :model :r-squared :aic :bic :equation :best-fit keys. AIC and BIC values may be nil when insufficient data points. Options: :best-fit-marker - string to show for best fit (default "✓") :plotted-marker - string to show for plotted but not best (default "")
:tolerance - fraction within best r-squared to mark as plotted (default 0.01)
Prepare model table rows for single-impl regression display.
Returns vector of row maps
with :model :r-squared :aic :bic :equation :best-fit keys.
AIC and BIC values may be nil when insufficient data points.
Options:
:best-fit-marker - string to show for best fit (default "✓")
:plotted-marker - string to show for plotted but not best (default "")
:tolerance - fraction within best r-squared to mark as
plotted (default 0.01)(prepare-regression-model-table-multi-impl by-impl impl-keys options)Prepare model table rows for multi-impl regression display. Returns vector of row maps with :implementation :model :r-squared :aic :bic :equation :best-fit.
Options same as prepare-regression-model-table.
Prepare model table rows for multi-impl regression display. Returns vector of row maps with :implementation :model :r-squared :aic :bic :equation :best-fit. Options same as prepare-regression-model-table.
(prepare-regression-points extract-data
{:keys [axis impl-axis has-error-bounds? metric]})Prepare data points for regression scatter plot. Returns {:points [...] :total-scale number :unit string :x-vals [...]} or nil. Points have keys: x, y, and optionally yLower, yUpper for error bounds. For multi-impl mode, points also have :impl key.
Prepare data points for regression scatter plot.
Returns {:points [...] :total-scale number :unit string :x-vals [...]} or nil.
Points have keys: x, y, and optionally yLower, yUpper for error bounds.
For multi-impl mode, points also have :impl key.(prepare-regression-residuals {:keys [valid-data total-scale]}
{:keys [axis impl-axis has-error-bounds? models
by-impl impl-keys]})Compute residual points for plotting. Returns vector of point maps with x, residual, and model or impl key.
Compute residual points for plotting. Returns vector of point maps with x, residual, and model or impl key.
(with-domain-regression-data data-map opts handlers)Orchestrate domain-regression rendering by iterating over metrics and implementations, calling the provided render functions at appropriate points.
The opts map must contain: :regression-id - key for regression in data-map (default :regression) :extract-id - key for extract in data-map (default :extract) :log-log-id - key for log-log in data-map (default :log-log) :tolerance - tolerance for selecting plotted models (default 0.01) :table-options - options for prepare-regression-model-table functions
The handlers map must contain render functions: :render-log-log-charts - (fn [{:keys [title axis metric impl-axis points line-pts residual-pts chart-opts]}] ...) :render-model-heading - (fn [{:keys [title axis metric impl-axis]}] ...) :render-model-table - (fn [{:keys [table-rows multi-impl?]}] ...) :render-regression-charts - (fn [{:keys [points line-pts residual-pts y-title residual-title axis chart-opts multi-impl?]}] ...)
For multi-impl mode, the impl-key is included in callback maps. For single-impl mode, slope/r-squared from log-log are included for display.
Orchestrate domain-regression rendering by iterating over metrics and
implementations, calling the provided render functions at appropriate points.
The opts map must contain:
:regression-id - key for regression in data-map (default :regression)
:extract-id - key for extract in data-map (default :extract)
:log-log-id - key for log-log in data-map (default :log-log)
:tolerance - tolerance for selecting plotted models (default 0.01)
:table-options - options for prepare-regression-model-table functions
The handlers map must contain render functions:
:render-log-log-charts - (fn [{:keys
[title axis metric impl-axis points
line-pts residual-pts chart-opts]}] ...)
:render-model-heading - (fn [{:keys
[title axis metric impl-axis]}] ...)
:render-model-table - (fn [{:keys [table-rows multi-impl?]}] ...)
:render-regression-charts - (fn [{:keys [points line-pts residual-pts
y-title residual-title axis
chart-opts multi-impl?]}] ...)
For multi-impl mode, the impl-key is included in callback maps.
For single-impl mode, slope/r-squared from log-log are included for display.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |