Models

rascal.models.normalise_input(x, y)[source]

Transforms inputs to have unit variance

rascal.models.poly_cost_function(a, x, y, degree)[source]

Polynomial cost function. Returns the absolute difference between the target value and predicted values.

Parameters
  • a (list) – Polynomial coefficients

  • x (list) – Values to evaluate polynomial at

  • y (list) – Target values for each x

  • degree (int) – Polynomial degree

Returns

residual – y - f(x)

Return type

list

rascal.models.polynomial(a, degree=3)[source]

Returns a lambda function which computes an nth order polynormal:

f(x, a) = sum_i (a[degree-i] * x**i )

rascal.models.robust_polyfit(x, y, degree=3, x0=None)[source]

Perform a robust polyfit given a set of values (x,y).

Specifically this function performs a least squares fit to the given data points using the robust Huber loss. Inputs are normalised prior to fitting.

Parameters
  • x (list) – Data points

  • y (list) – Target data to fit

  • degree (int) – Polynomial degree to fit

  • x0 (list or None) – Initial coefficients

Returns

p – Polynomial coefficients

Return type

list