fitcontimodels: train models for continuous label

Description Usage Arguments Value Examples

View source: R/digital_pathology.R

Description

this function can automatically split the train test datasets, and train lm lasso and svr models for continuous label and gain the MSE on test set and models. Also plot the prediction vs true y of test data.

Usage

1
2
3
4
5
6
7
fitcontimodels(
  data,
  frac = 0.8,
  seed = 12345,
  models = c("lm", "lasso", "svr"),
  kernel = "linear"
)

Arguments

data

a data frame with feature and label, the column name of label should be set at the last column.

frac

a one-dimension numeric data between (0,1). The proportion of train_data.The default value is 0.8.

seed

the seed of split dataset into train and test data, the default value is 12345.

models

a vector of model names want to be trained.the default value is c("lm","lasso","svr"),you can input any subset of default value expect null.

kernel

the kernel in svm model.choose one of "linear","polynomial","radial basis","sigmoid".

Value

a list of MSE and models.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
#create dataset
set.seed(12)
x1 <- 1:100
x2 <- seq(2,18,length.out = 100)+rnorm(100,3,4)
y <- 4x1 - 3x2+ rnorm(100,0,2)
data <- data.frame(x1=x1,x2=x2,y=y)
results <- fitcontimodels(data)

## End(Not run)

mimic0127/StatComp21097 documentation built on Dec. 24, 2021, 1:28 a.m.