SVR | R Documentation |
Wrapper R6 Class of e1071::svm function that can be used for LESSRegressor and LESSClassifier
R6 Class of SVR
less::BaseEstimator
-> less::SklearnEstimator
-> SVR
new()
Creates a new instance of R6 Class of SVR
SVR$new( scale = TRUE, kernel = "radial", degree = 3, gamma = NULL, coef0 = 0, cost = 1, cache_size = 40, tolerance = 0.001, epsilon = 0.1, shrinking = TRUE, cross = 0, probability = FALSE, fitted = TRUE )
scale
A logical vector indicating the variables to be scaled. If scale is of length 1, the value is recycled as many times as needed. Per default, data are scaled internally (both x and y variables) to zero mean and unit variance. The center and scale values are returned and used for later predictions (default: TRUE)
kernel
The kernel used in training and predicting. Possible values are: "linear", "polynomial", "radial", "sigmoid" (default is "radial")
degree
Parameter needed for kernel of type polynomial (default: 3)
gamma
Parameter needed for all kernels except linear (default: 1/(data dimension))
coef0
Parameter needed for kernels of type polynomial and sigmoid (default: 0)
cost
Cost of constraints violation (default: 1)—it is the ‘C’-constant of the regularization term in the Lagrange formulation (default: 1)
cache_size
Cache memory in MB (default: 40)
tolerance
Tolerance of termination criterion (default: 0.001)
epsilon
Epsilon in the insensitive-loss function (default: 0.1)
shrinking
Option whether to use the shrinking-heuristics (default: TRUE)
cross
If a integer value k>0 is specified, a k-fold cross validation on the training data is performed to assess the quality of the model: the accuracy rate for classification and the Mean Squared Error for regression (default: 0)
probability
Logical indicating whether the model should allow for probability predictions (default: FALSE)
fitted
Logical indicating whether the fitted values should be computed and included in the model or not (default: TRUE)
svr <- SVR$new() svr <- SVR$new(kernel = "polynomial")
fit()
Fit the SVM model from the training set (X, y).
SVR$fit(X, y)
X
2D matrix or dataframe that includes predictors
y
1D vector or (n,1) dimensional matrix/dataframe that includes response variables
Fitted R6 Class of SVR
data(abalone) split_list <- train_test_split(abalone[1:100,], test_size = 0.3) X_train <- split_list[[1]] X_test <- split_list[[2]] y_train <- split_list[[3]] y_test <- split_list[[4]] svr <- SVR$new() svr$fit(X_train, y_train)
predict()
Predict regression value for X0.
SVR$predict(X0)
X0
2D matrix or dataframe that includes predictors
The predict values.
svr <- SVR$new() svr$fit(X_train, y_train) preds <- svr$predict(X_test) svr <- SVR$new() preds <- svr$fit(X_train, y_train)$predict(X_test) preds <- SVR$new()$fit(X_train, y_train)$predict(X_test) print(head(matrix(c(y_test, preds), ncol = 2, dimnames = (list(NULL, c("True", "Prediction"))))))
get_estimator_type()
Auxiliary function returning the estimator type e.g 'regressor', 'classifier'
SVR$get_estimator_type()
svr$get_estimator_type()
clone()
The objects of this class are cloneable with this method.
SVR$clone(deep = FALSE)
deep
Whether to make a deep clone.
e1071::svm()
## ------------------------------------------------ ## Method `SVR$new` ## ------------------------------------------------ svr <- SVR$new() svr <- SVR$new(kernel = "polynomial") ## ------------------------------------------------ ## Method `SVR$fit` ## ------------------------------------------------ data(abalone) split_list <- train_test_split(abalone[1:100,], test_size = 0.3) X_train <- split_list[[1]] X_test <- split_list[[2]] y_train <- split_list[[3]] y_test <- split_list[[4]] svr <- SVR$new() svr$fit(X_train, y_train) ## ------------------------------------------------ ## Method `SVR$predict` ## ------------------------------------------------ svr <- SVR$new() svr$fit(X_train, y_train) preds <- svr$predict(X_test) svr <- SVR$new() preds <- svr$fit(X_train, y_train)$predict(X_test) preds <- SVR$new()$fit(X_train, y_train)$predict(X_test) print(head(matrix(c(y_test, preds), ncol = 2, dimnames = (list(NULL, c("True", "Prediction")))))) ## ------------------------------------------------ ## Method `SVR$get_estimator_type` ## ------------------------------------------------ svr$get_estimator_type()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.