JuliaGaussianProcesses / Stheno.jl

Probabilistic Programming with Gaussian processes in Julia
Other
340 stars 26 forks source link

Plotting Recipes #25

Closed willtebbutt closed 5 years ago

willtebbutt commented 5 years ago

It's useful to be able to produce nice pretty plots of GPs in 1 dimension. Currently, this is a bit of a pain because no plotting recipes have been implemented. If we implemented some, it would significantly simplify a lot of the plotting that we do.

(If you're interested in making this happen, I'm happy to discuss)

ritesh99rakesh commented 5 years ago

I want to work on this issue. As I am applying for GSoC'19 under Turing for GP project, I think that solving this issue will ease implementation of papers for Turing model zoo. Please guide me on how to proceed with this issue.

willtebbutt commented 5 years ago

Hi @ritesh99rakesh thanks for your interest. In the first instance it would be great to be able to provide an interface along the lines of

plot(f, xmin, xmax)

where f is a GP that's assumed to be 1-dimensional, and xmax and xmin are real numbers that say what range to plot the GP on. You could look here or at any of the other examples for ideas - they all follow the same basic pattern (and you'll quickly see that there's a lot of repeated code -- hence this issue :slightly_smiling_face: ):

  1. Plot the mean.
  2. Fill +/- 3 std. devs. around the mean with fairly low alpha.
  3. Plot some samples.

Pseudo-code for this might be something like:

x_plot = range(xmin, xmax; length=N_plot)
mean, std = marginals(f(x_plot))
samples = rand(f(x_plot), number_of_samples)

# plot_mean
# plot_mean +/- 3 std
# plot_samples

The second example on the landing page also provides a really good example of what I'm on about. In particular if you look at the Latent Function bit of the figure, you can see an example of what I mean by the above.

I was imagining that we would integrate with Plots.jl. In particular take a look at the recipes documentation. I've not really worked with recipes in plots before now, so I'll leave it to you to figure out how all of that works.

Please do open a work-in-progress PR as early as possible so that we can discuss the design a bit.

I would suggest adding your code to a file called src/util/plotting.jl and including it after the include("util/model.jl") line in src/Stheno.jl. Please do let me know if there's anything here that's not clear :slightly_smiling_face: .

nathanaelbosch commented 5 years ago

Hi @willtebbutt, I would like to help with this issue. I think I already have a reasonable proposal that should make basic plotting easier, especially regarding the basic functionality of plotting the mean +/- 3 std. devs. I also implemented support for the plotting of samples, as well as specifying the type of the sample plot (such as :line or :scatter), but I'm less sure here about the best design.

I also have two example scripts, corresponding to the two examples on the landing page. I am not sure how to best share them with you so please let me know about that.

Overall, I am quite new to Julia so I hope I followed common practices, and this is also my first ever open source contribution :) I will open a pull issue shortly (my first open source contribution ever!), and I'm looking forward to your feedback!

nathanaelbosch commented 5 years ago

I created two gists in order to share the two example scripts, which are modifications of the two examples that were used for the landing page plots: simple_sensor_fusion.jl process_decomposition.jl