The aim of this script is to create in R the following bivariate SVR model (the observations are represented with blue dots and the predictions with the orange 3D surface) :

We start by setting the working folder and loading the dataset

setwd("[WORKING FOLDER]")

#loading the dataset

dataset = read.csv('dataset.csv')

whose first 40 rows over 1000 are as follows :

Then we build the SVR regressor for the dataset with the « eps-regression » type (in order to build a non linear model) :

#Fitting the SVR to the dataset

#install.packages('e1071')

library(e1071)

regressor = svm(formula = C ~ ., data = dataset, type = "eps-regression")

Finally, we display in a 3D space the observed and predicted Price along the z axis, where x and y axis correspond to Paleonium and Pressure.

#visualizing the observations and predictions in a 3D space

#install.packages('plotly')

library(plotly)

Paleonium = dataset$A

Pressure = dataset$B

Price = dataset$C

plot_ly(x=as.vector(Paleonium),y=as.vector(Pressure),z=Price, type="scatter3d", mode="markers", name = "Obs", marker = list(size = 3)) %>%

add_trace(x=as.vector(Paleonium),y=as.vector(Pressure),z=predict(regressor, newdata=dataset), type = "mesh3d", name = "Preds")

The above code produces the following 3D graph where the predictions take the shape of a orange 3D surface and the observations are represented with blue dots. The model is fitting relatively well the observations since the blue dots are wrapping the 3D surface very closely.