Recursive interpolation (recursive_interp)#

Holds recursive interpolation class. This includes the recursive training algorithm and consistency checks.

See Recursive interpolation for example usage.

Classes:

RecursiveInterp(model_cls, derivatives, ...)

Class to perform a recursive interpolation (maybe using weighted extrapolation) and then save the information necessary to predict arbitrary interior points.

class thermoextrap.recursive_interp.RecursiveInterp(model_cls, derivatives, edge_beta, max_order=1, tol=0.01, rng=None)[source]#

Bases: object

Class to perform a recursive interpolation (maybe using weighted extrapolation) and then save the information necessary to predict arbitrary interior points. Training performs recursive algorithm to meet desired accuracy. Prediction uses the learned piecewise function.

Parameters:

Methods:

get_data(beta)

Obtains data at the specified state point.

getData(beta)

Obtains data at the specified state point.

recursive_train(beta1, beta2[, data1, ...])

Recursively trains interpolating models on successively smaller intervals until error tolerance is reached.

recursiveTrain(beta1, beta2[, data1, data2, ...])

Recursively trains interpolating models on successively smaller intervals

sequential_train(beta_train[, verbose])

Trains sequentially without recursion.

sequentialTrain(beta_train[, verbose])

Trains sequentially without recursion.

predict(beta)

Makes a prediction using the trained piecewise model.

check_poly_consistency([do_plot])

If the interpolation model is a polynomial, checks to see if the polynomials are locally consistent.

checkPolynomialConsistency([do_plot])

If the interpolation model is a polynomial, checks to see if the polynomials

get_data(beta)[source]#

Obtains data at the specified state point. Can modify to run MD or MC simulation, load trajectory or data files, etc. MUST return two things, the observable data and the potential energy data with the rows being separate configurations/time steps and the columns of the observable being the observable vector elements. The observable data can be 1 or 2 dimensional but the potential energy data should have only one dimension. This function just uses the toy ideal gas model that comes with lib_extrap.

getData(beta)[source]#

Obtains data at the specified state point.

Deprecated since version 0.2.0: Use get_data instead.

MUST return two things, the observable data and the potential energy data with the rows being separate configurations/time steps and the columns of the observable being the observable vector elements. The observable data can be 1 or 2 dimensional but the potential energy data should have only one dimension. This function just uses the toy ideal gas model that comes with lib_extrap.

recursive_train(beta1, beta2, data1=None, data2=None, recurse_depth=0, recurse_max=10, beta_avail=None, verbose=False, do_plot=False, plot_func=None)[source]#

Recursively trains interpolating models on successively smaller intervals until error tolerance is reached. The next state point to subdivide an interval is chosen as the point where the bootstrapped error is the largest. If beta_avail is not None, the closest state point value in this list will be used instead. This is useful when data has already been generated at specific state points and you do not wish to generate more.

recursiveTrain(beta1, beta2, data1=None, data2=None, recurse_depth=0, recurse_max=10, beta_avail=None, verbose=False, do_plot=False, plot_func=None)[source]#

Recursively trains interpolating models on successively smaller intervals

Deprecated since version 0.2.0: Use recursive_train instead.

interval is chosen as the point where the bootstrapped error is the largest. If beta_avail is not None, the closest state point value in this list will be used instead. This is useful when data has already been generated at specific state points and you do not wish to generate more.

sequential_train(beta_train, verbose=False)[source]#

Trains sequentially without recursion. List of state point values is provided and training happens just on those without adding points.

sequentialTrain(beta_train, verbose=False)[source]#

Trains sequentially without recursion. List of state point values is provided and

Deprecated since version 0.2.0: Use sequential_train instead.

predict(beta)[source]#

Makes a prediction using the trained piecewise model. Note that the function will not produce output if asked to extrapolate outside the range it was trained on.

check_poly_consistency(do_plot=False)[source]#

If the interpolation model is a polynomial, checks to see if the polynomials are locally consistent. In other words, we want the coefficients between neighboring regions to match closely to each other, and to the larger region composed of the two neighboring sub-regions. Essentially, this checks to make sure the local curvature is staying constant as you zoom in. If it is, your function in the region is well-described by the given order of polynomial and you can have higher confidence in the resulting model output. Will also generate plots as a visual check if desired.

checkPolynomialConsistency(do_plot=False)[source]#

If the interpolation model is a polynomial, checks to see if the polynomials

Deprecated since version 0.2.0: Use check_poly_consistency instead.

neighboring regions to match closely to each other, and to the larger region composed of the two neighboring sub-regions. Essentially, this checks to make sure the local curvature is staying constant as you zoom in. If it is, your function in the region is well-described by the given order of polynomial and you can have higher confidence in the resulting model output. Will also generate plots as a visual check if desired.