Local Regression Simplified

Implementation of Multi-variate local polynomial regression.

  • This file is a part of Personal Programming Project (PPP) coursework in Computational Materials Science (CMS) M.Sc. course in Technische Universität Bergakademie Freiberg.

  • This file is a part of the project titled Application of statistical learning to predict material properties.

  • For a given number of data points, the algorithm fits a polynomial of given degree to the data points in a specified neighbourhood.

  • Given response variables and predictor variables, this can be used to estimate a regression function.

  • At fitting points the underlying function is assumed to be smooth and k-times differentiable to fit a polynomial of degree k.

References

Cleveland, W.S. (1979) “Robust Locally Weighted Regression and Smoothing Scatterplots”. Journal of the American Statistical Association 74 (368): 829-836.

class localRegressionSimple.LocalRegressionSimple(frac=None)

Bases: object

Multi-variate local polynomial regression.

:meth:`eval_dist` : Method that computes the distances of a given point

and its counterparts in a specified window.

:meth:`eval_weights` : Method that computes the weights from the

normalized distances within the window. This method specifically returns values of tricube weighting function evaluation.

:meth:`fit` : Method that provides the initial wrapper for the methods

mentioned above.

:meth:`predict` : Method that utilizes the learned data matrix to

evaluate the predictor variables.

frac

Fraction of data to be used while estimating polynomial.

Type:

float

eval_dist(window, x)

Method to evaluate distances between a point x and other points in a specified window.

Parameters:
  • window (array) – Array of points from which distance is to be determined.

  • x (array) – Point from which distances are to be determined.

Returns:

dist – Array with distances in the window.

Return type:

array

eval_weights(norm_dist)

Method to evaluate weights using tricube weight function given normalized distances.

Parameters:

norm_dist (array) – Array consisting of normalized distances.

Returns:

weights – Array consisting of determined weights.

Return type:

array

fit(x, y)

Method that evaluates the fit using local polynomial regression.

Parameters:
  • x (array) – Independent variables.

  • y (array) – Dependent variables.

Returns:

d_mat – Corresponding data matrix obtained after regressing given values.

Return type:

array

predict(x, d_mat=None)

Method that utilizes given data matrix and independent variables to evaluate the predictor variables.

Parameters:
  • x (array) – Values of independent variables at which predictions are made.

  • d_mat (array) – Corresponding data matrix, defaults to the data matrix obtained after fitting the data. Running fit() before this is absolutely essential.

Returns:

y_pred – Array consisting of predicted dependent variables.

Return type:

array