lr_cd.lr_plotting

Module Contents

Functions

plot_lr(X, y, intercept, coef)

Visualize the "lr_cd" linear regression model.

lr_cd.lr_plotting.plot_lr(X, y, intercept, coef)[source]

Visualize the “lr_cd” linear regression model.

This function takes actual data points and an estimated regression line, displaying them together in a scatter plot.

Parameters:
  • X (ndarray) – The observed data ‘x’, the independent variable

  • y (ndarray) – The observed data ‘y’, the dependent variable. Both ‘x’ and ‘y’ should be continuous and of the same length.

  • intercept (float) – Optimized intercept generated by ‘lr_cd’ function. It will be used to calculate the estimated values using observed data ‘x’.

  • coef (ndarray) – Optimized coefficient weights vector. It will be used to calculate the estimated values using observed data ‘x’.

Return type:

A scatter plot of the observed data points overlayed with a line coming from the fitted weights.

Examples

>>> from lr_cd.lr_plotting import plot_lr
>>> X = array([[0.69646919],
   [0.28613933],
   [0.22685145],
   [0.55131477],
   [0.71946897],
   [0.42310646],
   [0.9807642 ],
   [0.68482974],
   [0.4809319 ],
   [0.39211752]])
>>> y = array([[6.34259481],
   [4.68506992],
   [4.54477713],
   [5.63500251],
   [6.45668483],
   [5.14153898],
   [6.8534962 ],
   [5.96761896],
   [5.88398172],
   [5.61370977]])
>>> intercept = 0.42167642
>>> coef = array([1.88190714])
>>> plot_lr(X, y, intercept, coef)