Skip to content

ScoreEstimator

ScoreEstimator(model=None, solver='dsm', solver_kwargs=None, device='cpu', random_state=0)

Bases: BaseEstimator

Estimate score functions from snapshot data.

Parameters:

  • model (Module, default: None ) –

    Score model (dimensions of input change depending on solver)

  • solver (dsm, default: 'dsm' ) –

    Solver backend.

  • solver_kwargs (dict, default: None ) –

    Extra keyword arguments passed to the selected solver. For solver='dsm', this can include scheduler_factory to configure the learning-rate scheduler.

  • device (str or device, default: 'cpu' ) –

    Device used for training 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 state dimension, set during fit.

  • times_ (ndarray of shape (n_times,)) –

    Sorted unique training times, set during fit.

  • model_ (Module) –

    Fitted score model used at inference time, set during fit. The input of this fitted model is (x, sigma, t), dimension ndim + 2.

  • loss_ (ndarray of shape (n_epochs,)) –

    Recorded training loss history.

  • sigma_ (torch.Tensor of shape (L,)) –

    Noise schedule used by the fitted DSM model.

error(X, y=None, **kwargs)

Compute per-time energy distance between generated and observed data.

Parameters:

  • X (ndarray of shape (n_samples, ndim + 1)) –

    Input data with time in the last column.

  • y (None, default: None ) –

    Ignored. Present for future compatibility with sklearn.

  • **kwargs (dict, default: {} ) –

    Extra keyword arguments forwarded to the sampler.

Returns:

  • scores ( ndarray of shape (n_times,) ) –

    Energy distance at each unique time in X.

fit(X, y=None)

Fit the score estimator on time-augmented data.

Parameters:

  • X (ndarray of shape (n_samples, ndim + 1)) –

    Input data where the last column contains time.

  • y (None, default: None ) –

    Ignored. Present for future compatibility with sklearn.

Returns:

predict(X)

Predict score vectors for input samples.

Parameters:

  • X (array-like of shape (n_samples, ndim + 1)) –

    Inputs containing state and time columns.

Returns:

  • score ( ndarray of shape (n_samples, ndim) ) –

    Predicted score vectors.

sample(X, **kwargs)

Generate samples using the fitted score model.

Parameters:

  • X (ndarray of shape of shape (n_samples, ndim + 1)) –

    Conditioning samples with time in the last column.

  • **kwargs (dict, default: {} ) –

    Extra keyword arguments forwarded to the sampler.

Returns:

  • gen ( ndarray of shape (nsamples, ndim + 1) ) –

    Generated samples with time in the last column.

score(X, y=None, **kwargs)

Return the negated mean error for sklearn compatibility. This defines a proper score that can be used for cross-validation.

Parameters:

  • X (ndarray of shape (n_samples, ndim + 1)) –

    Input data with time in the last column.

  • y (None, default: None ) –

    Ignored. Present for future compatibility with sklearn.

  • **kwargs (dict, default: {} ) –

    Extra keyword arguments forwarded to error.

Returns:

  • float –

    Negated mean error. Larger values indicate better fit.