Introduction to the
Recently I was reading some articles about the application of Bayesian deep learning in reliability. I came across the following article, published in ITR of reliability.
This paper mainly introduces the use of Bayesian deep learning to predict the remaining service life of products, but the traditional deep learning method can only get the estimated value of the future time point, and cannot contain uncertain factors, while the use of Bayesian deep learning can finally get the distribution of the predicted value of the future time point.
In the simulation stage, a 3D density function graph obtained by MATLAB is given.
The main purpose is to explain the distribution of residual service life (RUL) at future time points predicted by using this method, the corresponding point estimates and true values. It can be seen that the point estimation of this method is very close to the real value, and the kernel density function of the corresponding point is also given. From this kernel density function you can find a 95%95\%95% prediction interval.
It seems that the content is too much, this article is not a literature interpretation 😁. Mainly reproduce this diagram, then officially start!
The tutorial
The GGplot2 Plots and their extension packs don’t seem to be very good for this 3D graphics, but there are some tutorials available: 3D Plots with ggplot2 and Plotly. Here we draw primarily using the scatter3D function in the plot3D package, or try using the Scatterplot3d package.
First, construct some simulated data as examples. Here, we assume that the density function at each time point follows a normal distribution, with mean values of 1:5 and standard deviations of 1. Color is my favorite color, refer to Xiaoming’s tweet: R language GGplot2 to draw a set of beautiful color and adjust the font simple small examples.
mean1 = 1:5 # Describe the mean value of the corresponding density function at different times
len = 1000
col = c("#02B1e6"."#E81D22"."#F9BC15"."#8015f9"."#20e81d"."#e64602")
x <- seq(-5.10.length = len)
y <- seq(1.5.length = 5)
z = matrix(NA.length(x),5)
for(i in 1:length(mean1)){
z[,i] = dnorm(x,mean1[i],1)}Copy the code
The scatter3D function is then used to build an empty three-dimensional bin (alpha=0). The first three arguments of this function correspond to the x, y, and z coordinates respectively, and bTY (boxType) represents the type of the box, using a form similar to the one in the literature, but we will show the other forms later. Phi, theta mainly adjusts the upper and lower angles and the left and right angles. Ticktype = “Detailed” shows the coordinate axes in detail.
If you are interested in other parameters, see this tutorial: Impressive Package for 3D and 4D Graph-R Software and Data visualization.
scatter3D(x, rep(1,len), z[,1], bty = "b2",colkey = FALSE,
phi = 14,theta = 45,
pch = 18,alpha = 0,ticktype = "detailed", expand =0.5,
ylim = c(1.5),zlim = c(0.0.5),
xlab = "RUL(10s)", ylab = "Time(10s)", zlab = "Kernel Distribution"
)
Copy the code
Then you add the density function diagrams and point estimates using add = TRUE inside the parameters.
for(i in 1:length(mean1)){
scatter3D(x, rep(i,len), z[,i], add = TRUE,type ='l', col = col[i], pch = 16)
scatter3D(x[which.max(z[,i])], y[i], 0 , add = TRUE, type ='h', col = col[i], pch = 16)}Copy the code
At this time, the 3D density function graph similar to that in the literature is basically obtained. The true value can also be added to the loop, which I won’t do here.
You can adjust the BTY parameter if you want to change the box style, for example: bty = “g”, bty = “f”, etc.
Xiaobian has something to say
- There is actually a legend missing from this diagram, which I haven’t added yet, note here.
- This series should continue with drawings that are commonly used in the ie direction. Note that the diagram drawn in this direction will be relatively simple, the difficulty lies in the model establishment and theoretical derivation, so xiaobian also does not know whether it is helpful for readers to reproduce these diagrams, mainly the record of my own scientific research.