projplot
Submodules
Package Contents
Functions
|
Generate a matrix of projection plot x-values. |
|
Create a projection plot based on the output of |
|
Generate projection plot data from the objective function and an x-value matrix returned by |
|
Generate projection plots. |
- projplot.proj_xvals(x_opt, x_lims, n_pts)[source]
Generate a matrix of projection plot x-values.
- Parameters
x_opt (NumPy array) – An array of parameter values.
x_lims (NumPy array) – An array of limits or a 2 x x_opt.shape[0] matrix of lower and upper limits for each parameter.
n_pts (int) – The number of points to plot.
- Returns
An array of all possible combinations of the x-values based on the limits (x_lims) and optimal values (x_opt).
- Return type
(NumPy array)
Example
>>> proj_xvals(np.array([1,15]), np.array([[0,2], [10, 20]]), 3) array([[ 0., 15.], [ 1., 15.], [ 2., 15.], [ 1., 10.], [ 1., 15.], [ 1., 20.]])
- projplot.proj_plot_show(plot_data, vlines=None)[source]
Create a projection plot based on the output of
proj_data().- Parameters
plot_data (DataFrame) – A DataFrame that contains columns for the calculated y-value, varying x value and the respective x_opt name associated with the varying x.
vlines (optional Array) – An array of x-values to plot a vertical line at for each projection plot. The length of this array should equal the number of parameters being optimized.
- Returns
A plot for each unique x_opt using the x and y values in plot_data with optional vertical lines.
- projplot.proj_data(fun, x_vals, x_names=[], vectorized=False)[source]
Generate projection plot data from the objective function and an x-value matrix returned by
proj_xvals().- Parameters
fun (Python function) – The objective function that is being optimized.
x_vals (NumPy array) – A matrix of the x_vals, this should be outputted from proj_xvals().
x_names (optional List) – A list of the names respective to varying x-values for plotting.
vectorized (Bool) – True if the objective function is vectorized, else False.
- Returns
DataFrame with columns y, x, and variable containing: the y-value in each projection plot; the corresponding x-values; and the name of the variables in x_names.
- Return type
(pandas.DataFrame)
- projplot.proj_plot(fun, x_opt, x_lims, x_names=None, n_pts=100, vectorized=False, plot=True, opt_vlines=False)[source]
Generate projection plots.
- Parameters
fun (Python function) – The objective function that is being optimized
x_opt (NumPy array) – An array of parameter values
x_lims (NumPy array) – An array of limits or a 2 x x_opt.shape[0] matrix of lower and upper limits for each parameter
x_names (anyof List None) – A list of the names respective to varying x-values for plotting
n_pts (int) – The number of points to plot
vectorized (Bool) – TRUE if the objective function is vectorized, else FALSE
plot (Bool) – TRUE if the user wants a plot outputted, else FALSE
opt_vlines (Bool) – If this parameter is set to True, then a vertical line is plotted at each parameter’s optimal value. The default is set to False.
- Returns
If
plot=False, the y-value in each projection plot appended to the x-values in a DataFrame format that’s amenable to plotting is returned. Ifplot=True, a plot handle of the projection plots, which is a plot for each varying x_opt is returned and the plot is displayed.