我rfe对caret库中的功能有疑问.在插入符号主页链接上,他们提供以下RFE算法:
算法
对于这个例子,我使用rfe具有3倍交叉验证的功能和具有线性SVM和5倍交叉验证的列车功能.
library(kernlab)
library(caret)
data(iris)
# parameters for the tune function, used for fitting the svm
trControl <- trainControl(method = "cv", number = 5)
# parameters for the RFE function
rfeControl <- rfeControl(functions = caretFuncs, method = "cv",
number= 4, verbose = FALSE )
rf1 <- rfe(as.matrix(iris[,1:4]), as.factor(iris[,5]) ,sizes = c( 2,3) ,
rfeControl = rfeControl, trControl = trControl, method = "svmLinear")
Run Code Online (Sandbox Code Playgroud)
rfe 将数据(150个样本)分成3倍train功能将在训练集(100个样本)上运行,具有5倍交叉验证以调整模型参数 - …I'm trying to use Snakemake rules within a loop so that the rule takes the output of the previous iteration as input. Is that possible and if yes how can I do that?
Here is my example
mkdir -p test
echo "SampleA" > test/SampleA.txt
echo "SampleB" > test/SampleB.txt
Run Code Online (Sandbox Code Playgroud)
SAMPLES = ["SampleA", "SampleB"]
rule all:
input:
# Output of the final loop
expand("loop3/{sample}.txt", sample = SAMPLES)
#### LOOP ####
for i in list(range(1, 4)):
# Setup …Run Code Online (Sandbox Code Playgroud) 我无法找到适合我数据的正确曲线.如果比我更了解情况的人有更好的拟合曲线的想法/解决方案,我将非常感激.
数据:目的是从y预测x
dat <- data.frame(x = c(15,25,50,100,150,200,300,400,500,700,850,1000,1500),
y = c(43,45.16,47.41,53.74,59.66,65.19,76.4,86.12,92.97,
103.15,106.34,108.21,113) )
Run Code Online (Sandbox Code Playgroud)
这是我走了多远:
model <- nls(x ~ a * exp( (log(2) / b ) * y),
data = dat, start = list(a = 1, b = 15 ), trace = T)
Run Code Online (Sandbox Code Playgroud)
哪个不合适:
dat$pred <- predict(model, list(y = dat$y))
plot( dat$y, dat$x, type = 'o', lty = 2)
points( dat$y, dat$pred, type = 'o', col = 'red')
Run Code Online (Sandbox Code Playgroud)
谢谢,F