neuromancer.plot module
Various helper functions for plotting.
- class neuromancer.plot.VisualizerClosedLoop(u_key='U_pred_policy', y_key='Y_pred_dynamics', r_key='Rf', d_key=None, ymin_key=None, ymax_key=None, umin_key=None, umax_key=None, policy=None, ctrl_outputs=None, savedir='test_control')[source]
Bases:
Visualizer
- class neuromancer.plot.VisualizerDobleIntegrator(dataset, model, policy, dynamics, verbosity, savedir, nstep=40, x0=array([[1.5], [1.5]]), training_visuals=False, trace_movie=False)[source]
Bases:
Visualizer
custom visualizer for double integrator example
- class neuromancer.plot.VisualizerOpen(model, verbosity, savedir, training_visuals=False, trace_movie=False, figname=None)[source]
Bases:
Visualizer
- class neuromancer.plot.VisualizerTrajectories(model, plot_keys, verbosity)[source]
Bases:
Visualizer
- class neuromancer.plot.VisualizerUncertaintyOpen(dataset, savedir, dynamics_name='dynamics')[source]
Bases:
Visualizer
- neuromancer.plot.cl_simulate(A, B, net, nstep=50, x0=array([[1.], [1.]]))[source]
- Parameters:
A
B
net
nstep
x0
- Returns:
- neuromancer.plot.get_colors(k)[source]
Returns k colors evenly spaced across the color wheel. :param k: (int) Number of colors you want. :return: (np.array, shape=[k, 3])
- neuromancer.plot.plot_loss_DPC(model, policy, A, B, dataset, xmin=-5, xmax=5, save_path=None)[source]
plot loss function for trained DPC model :param model: :param dataset: :param xmin: :param xmax: :param save_path: :return:
- neuromancer.plot.plot_loss_mpp(model, dataset, xmin=-2, xmax=2, save_path=None)[source]
plots loss function for multiparametric problem with 2 parameters :param model: :param dataset: :param xmin: :param xmax: :param save_path: :return:
- neuromancer.plot.plot_matrices(matrices, labels, figname)[source]
Plots and saves figure of a grid of matrices. Useful for inspecting layers of weights of neural networks.
- Parameters:
matrices – (list of lists of 2-way np.arrays) Grid of matrices to plot
labels – (list of lists of str) Labels for plotted matrices
figname – (str) Figure name ending with file extension of filetype to save as.
>>> import neuromancer.plot as plot >>> color_matrices = [[get_colors(k*j) for k in range(2, 4)] for j in range(8, 11)] >>> labels = [[f'{k*j} X 3 matrix' for k in range(2, 4)] for j in range(8, 11)] >>> plot_matrices(color_matrices, labels, 'matrix_grid.png')
- neuromancer.plot.plot_model_graph(model, data_keys, include_objectives=True, fname='model_graph.png')[source]
- neuromancer.plot.plot_policy_train(A, B, policy, policy_list, xmin=-5, xmax=5, save_path=None)[source]
- neuromancer.plot.plot_solution_mpp(model, xmin=-2, xmax=2, save_path=None)[source]
plots solution landscape for problem with 2 parameters and 1 decision variable :param net: :param xmin: :param xmax: :param save_path: :return:
- neuromancer.plot.plot_traj(data, figname=None)[source]
- Parameters:
data – (dict {str: np.array}) Dictionary of labels and time series
figname – (str)
- neuromancer.plot.pltCL(Y, R=None, U=None, D=None, X=None, ctrl_outputs=None, Ymin=None, Ymax=None, Umin=None, Umax=None, figname=None)[source]
plot input output closed loop dataset
- neuromancer.plot.pltCorrelate(X, figname=None)[source]
plot correlation matrices of time series data
- neuromancer.plot.pltOL(Y, Ytrain=None, U=None, D=None, X=None, figname=None)[source]
plot trained open loop dataset
- neuromancer.plot.pltPhase(X, figname=None)[source]
- Parameters:
X – (np.array, shape=[numpoints, {2,3}])
figname – (str) Filename for plot with extension for file type.
plot phase space for 2D and 3D state spaces
https://matplotlib.org/3.2.1/gallery/images_contours_and_fields/plot_streamplot.html
https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.streamplot.html
https://matplotlib.org/3.2.1/api/_as_gen/matplotlib.pyplot.quiver.html
http://kitchingroup.cheme.cmu.edu/blog/2013/02/21/Phase-portraits-of-a-system-of-ODEs/
http://systems-sciences.uni-graz.at/etextbook/sw2/phpl_python.html
>> import numpy as np >> import neuromancer.plot as plot >> x = np.stack([np.linspace(-10, 10, 100)]*100) >> y = np.stack([np.linspace(-10, 10, 100)]*100).T >> z = x**2 + y**2 >> xyz = np.stack([x.flatten(), y.flatten(), z.flatten()]) >> plot.pltPhase(xyz, figname='phase.png')
- neuromancer.plot.pltRecurrence(X, figname=None)[source]
plot recurrence of time series data