FlowEstimator
FlowEstimator(flow=None, growth=None, solver='pfm', solver_kwargs=None, device='cpu', random_state=0)
Bases: BaseEstimator
Flow estimator trained with one of the configured solver backends.
Supported solver names are given by SOLVER_FUNCS.
Parameters:
-
flow(Module or None, default:None) –Drift model.
-
growth(Module or None, default:None) –Optional growth model used by unbalanced solvers.
-
solver(str, default:'pfm') –Solver backend name.
-
solver_kwargs(dict or None, default:None) –Extra keyword arguments forwarded to the selected solver.
-
device(str or device, default:'cpu') –Device used for fitting and inference.
-
random_state(int or None, default:0) –Seed value. If ``None``, a random seed is drawn from the default global generator.
Attributes:
-
Ndim_(int) –Inferred spatial dimension set during
fit. -
flow_(Module) –Fitted drift model returned by the selected solver.
-
growth_(Module or None) –Fitted growth model returned by the selected solver.
-
loss_(ndarray of shape (n_epochs,)) –Recorded training loss history.
-
times_(ndarray of shape (n_times,)) –Sorted unique training times.
error(X, y=None, stoch=False, dt=0.01, pos=True)
Compute per-time energy distance over consecutive snapshot pairs.
Parameters:
-
X(array-like of shape (n_samples, ndim + 1)) –Samples from all time points with time in the last column.
-
y(ignored, default:None) –Present for sklearn API compatibility.
-
stoch(bool, default:False) –Whether to simulate with stochastic dynamics.
-
dt(float, default:0.01) –Integration step for sampling.
-
pos(bool, default:True) –Passed to
sampleto enforce nonnegative states in stochastic mode.
Returns:
-
scores(ndarray of shape (n_times - 1,)) –Energy distance for each consecutive pair
(t_k, t_{k+1}).
fit(X, y=None)
Fit flow parameters from time-augmented samples.
Parameters:
-
X(array-like of shape (n_samples, ndim + 1)) –Training data with time in the last column.
-
y(None, default:None) –Ignored. Present for future compatibility with sklearn.
Returns:
-
self(FlowEstimator) –Fitted estimator.
predict(X, stoch=False)
Predict flow vectors for input states.
Parameters:
-
X(array-like of shape (n_samples, ndim + 1)) –Inputs with time in the last column.
-
stoch(bool, default:False) –Whether to request stochastic output.
Returns:
-
y_pred(ndarray) –Predicted drift values.
sample(X, Dt, dt=0.01, stoch=False, pos=True)
Simulate trajectories from initial states over Dt.
Parameters:
-
X(array-like of shape (n_samples, ndim + 1)) –Initial states with time in the last column.
-
Dt(float) –Simulation horizon.
-
dt(float, default:0.01) –Integration step.
-
stoch(bool, default:False) –Whether to use stochastic model outputs.
-
pos(bool, default:True) –If
True, appliesreluto keep simulated states nonnegative in stochastic mode.
Returns:
-
x_final(ndarray of shape (n_samples, ndim)) –Simulated final states.
score(X, y=None, stoch=False, dt=0.01, pos=True)
Return the negated mean error for sklearn compatibility.
Parameters:
-
X(array-like of shape (n_samples, ndim + 1)) –Samples from all time points with time in the last column.
-
y(ignored, default:None) –Present for sklearn API compatibility.
-
stoch(bool, default:False) –Whether to simulate with stochastic dynamics.
-
dt(float, default:0.01) –Integration step for sampling.
-
pos(bool, default:True) –Passed to
sampleto enforce nonnegative states in stochastic mode.
Returns:
-
float–Negated mean error over consecutive snapshot pairs. Larger values indicate better fit.