segreg.analysis.plot_models

plot_models(func_arr, indep, dep, domain_begin_arr=None, domain_end_arr=None, extra_pts_arr=None, title=None, xlabel=None, ylabel=None, mark_extra_pts=True, scatter_size=3, scatter_color='gray', marker='o', legend=None, ax=None)[source]

Plots univariate functions together with scatter of the data.

This plotting utility is geared towards segmented regression problems where the function inputs would be the piecewise-linear segmented functions.

Notes

For plotting segmented regression models, it is recommended to pass in the bkpts via the parameter extra_pts_arr to ensure the plot looks correct. This is because the bkpts might not coincide with data points, and the plot interpolation between plotted points could appear wrong near the bkpts.

Parameters
  • func_arr (array-like) – An array of function objects. Each function should be defined on the domain of the independent data.

  • indep (array-like) – The independent data. Also called predictor, explanatory variable, regressor, or exogenous variable.

  • dep (array-like) – The dependent data. Also called response, regressand, or endogenous variable.

  • domain_begin_arr (array-like) – An array of float. Each element specifies the left endpoint of the domain to plot for corresponding function in func_arr. Must have same length as the parameter func_arr.

  • domain_end_arr (array-like) – An array of float. Each element specifies the right endpoint of the domain to plot for corresponding function in func_arr. Must have same length as the parameter func_arr.

  • extra_pts_arr (array-like) –

    An array of arrays. Each element is an array containing extra points to plot. The points are in the x-axis domain (ie: the domain of the independent data). Must have same length as the parameter func_arr. Each element must be either array-like or None.

    Eg: [ [1,2], [3] ].

    Eg: [ None, [4,5] ].

  • title (str) –

  • xlabel (str) –

  • ylabel (str) –

  • mark_extra_pts (bool) – If True, will add marker to any plotted extra points, as set by the parameter extra_pts_arr.

  • full_size_scatter (bool) –

  • scatter_size (int) –

  • scatter_color (str) –

  • marker (str) –

  • legend (array-like) – An array of str. Must have same length as the parameter func_arr.

  • ax (matplotlib axes object, default None) –