FitOptions reference#
FitOptions is a dataclass that controls everything: preprocessing,
clustering, and fitting. Every field has a sensible default — pass only what you need to change.
from pykinbiont import FitOptions
opts = FitOptions(
smooth=True,
smooth_method="rolling_avg",
multistart=True,
n_restart=30,
)
Smoothing#
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Enable smoothing before fitting |
|
|
|
Method: |
|
|
|
Window size for |
|
|
|
Window size for |
|
|
|
Fraction of data used for each LOWESS fit |
|
|
|
Bandwidth multiplier for Gaussian kernel |
|
|
|
Custom time grid for Gaussian resampling |
Blank subtraction and negative values#
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Subtract a blank OD from all curves |
|
|
|
OD value to subtract (used when |
|
|
|
Compute blank from curves labelled “blank” |
|
|
|
Handle OD values that go negative after blank subtraction |
|
|
|
|
|
|
|
Minimum OD floor for |
Scattering correction#
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Enable scattering correction |
|
|
|
Path to calibration CSV (required when |
|
|
|
|
Stationary phase trimming#
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Remove stationary-phase data before fitting |
|
|
|
Percentile of max OD used as stationarity threshold |
|
|
|
Smoothing window for derivative used to detect stationarity |
|
|
|
Window to confirm stationarity |
|
|
|
Minimum OD for a point to be considered in stationary phase |
Clustering#
Clustering is preprocessing, not fitting
Setting cluster=True runs k-means clustering on the curve shapes and populates
GrowthData.clusters, but does not fit growth models. Use preprocess() for
clustering, then fit() separately for model fitting.
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Run k-means clustering |
|
|
|
Number of clusters (≥ 2) |
|
|
|
Filter constant curves before clustering |
|
|
|
Remove constant curves entirely |
|
|
|
IQR multiplier for constant-curve detection |
|
|
|
Lower quantile for normalization |
|
|
|
Upper quantile for normalization |
|
|
|
Use exponential-phase prototypes for cluster shapes |
|
|
|
Number of k-means random restarts |
|
|
|
Maximum k-means iterations |
|
|
|
Convergence tolerance |
|
|
|
Random seed for reproducibility |
Fitting#
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Loss function: |
|
|
|
Run optimizer from |
|
|
|
Number of random restarts when |
|
|
|
Use AICc (corrected AIC) instead of AIC for model selection |
|
|
|
Window for growth rate derivative estimate |
|
|
|
Extra keyword arguments forwarded to the Julia optimizer |
opt_params#
Pass additional options to the underlying Optim.jl optimizer. Keys must be valid Julia
identifiers; values must be int, float, or bool:
opts = FitOptions(
opt_params={
"maxiters": 5000,
"abstol": 1e-8,
}
)
Example combinations#
Minimal — log-linear only, no preprocessing:
opts = FitOptions()
Smooth + blank subtraction:
opts = FitOptions(
smooth=True,
smooth_method="rolling_avg",
smooth_pt_avg=5,
blank_subtraction=True,
blank_value=0.015,
correct_negatives=True,
negative_method="thr_correction",
negative_threshold=0.001,
)
Robust multistart fitting:
opts = FitOptions(
multistart=True,
n_restart=50,
loss="L2",
aic_correction=True,
)