# NOT RUN {
data("auto_mpg")
train = s2Data(xL = auto_mpg$P1$xL, yL = auto_mpg$P1$yL, xU = auto_mpg$P1$xU)
# We create the C++ object calling the new method (constructor)
obj = new(s2net, train, 0) # 0 = regression
obj
# We call directly the $fit method of obj,
obj$fit(s2Params(lambda1 = 0.01,
lambda2 = 0.01,
gamma1 = 0.05,
gamma2 = 100,
gamma3 = 0.05), 1, 2)
# fitted model
obj$beta
# We can test the results using the unlabeled data
test = s2Data(xL = auto_mpg$P1$xU, yL = auto_mpg$P1$yU, preprocess = train)
ypred = obj$predict(test$xL, 0)
# }
# NOT RUN {
if(require(ggplot2)){
ggplot() +
aes(x = ypred, y = test$yL) + geom_point() +
geom_abline(intercept = 0, slope = 1, linetype = 2)
}
# }
# NOT RUN {
# }
Run the code above in your browser using DataCamp Workspace