小编Fab*_*n_G的帖子

R插入符号/如何在rfe工作中对列车进行交叉验证

rfecaret库中的功能有疑问.在插入符号主页链接上,他们提供以下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)
  • 从上面的算法我假设该算法可以使用2个嵌套的交叉验证:
    1. rfe 将数据(150个样本)分成3倍
    2. train功能将在训练集(100个样本)上运行,具有5倍交叉验证以调整模型参数 - …

r cross-validation rfe r-caret

9
推荐指数
1
解决办法
3166
查看次数

Snakemake using a rule in a loop

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

  1. Setup the test data
mkdir -p test
echo "SampleA" > test/SampleA.txt
echo "SampleB" > test/SampleB.txt
Run Code Online (Sandbox Code Playgroud)
  1. Snakemake
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)

python shell snakemake

6
推荐指数
2
解决办法
567
查看次数

R nls:拟合数据曲线

我无法找到适合我数据的正确曲线.如果比我更了解情况的人有更好的拟合曲线的想法/解决方案,我将非常感激.

数据:目的是从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

r nls

2
推荐指数
1
解决办法
1009
查看次数

标签 统计

r ×2

cross-validation ×1

nls ×1

python ×1

r-caret ×1

rfe ×1

shell ×1

snakemake ×1