Tôi tò mò nếu R có khả năng đặt đối tượng vào vectơ/danh sách/mảng/v.v. Tôi đang sử dụng gói randomforest để làm việc trên các tập hợp con của một đoạn dữ liệu lớn hơn và muốn lưu trữ từng phiên bản trong một danh sách. Nó sẽ là tương tự như sau:R đặt nhiều đối tượng randomForest vào một vector
answers <- c()
for(i in 1:10){
x <- round((1/i), 3)
answers <- (rbind(answers, x))
}
Lý tưởng nhất là tôi muốn làm một cái gì đó như thế này:
answers <- c()
for(i in 1:10){
RF <- randomForest(training, training$data1, sampsize=c(100), do.trace=TRUE, importance=TRUE, ntree=50,,forest=TRUE)
answers <- (rbind(answers, RF))
}
Đây là loại công trình nhưng đây là đầu ra cho một đối tượng RF duy nhất:
> RF
Call:
randomForest(x = training, y = training$data1, ntree = 50, sampsize = c(100), importance = TRUE, do.trace = TRUE, forest = TRUE)
Type of random forest: regression
Number of trees: 10
No. of variables tried at each split: 2
Mean of squared residuals: 0.05343956
% Var explained: 14.32
Trong khi điều này được đặt ra cho danh sách 'câu trả lời':
> answers
call type predicted mse rsq oob.times importance importanceSD
RF Expression "regression" Numeric,150000 Numeric,10 Numeric,10 Integer,150000 Numeric,16 Numeric,8
RF Expression "regression" Numeric,150000 Numeric,10 Numeric,10 Integer,150000 Numeric,16 Numeric,8
RF Expression "regression" Numeric,150000 Numeric,10 Numeric,10 Integer,150000 Numeric,16 Numeric,8
RF Expression "regression" Numeric,150000 Numeric,10 Numeric,10 Integer,150000 Numeric,16 Numeric,8
RF Expression "regression" Numeric,150000 Numeric,10 Numeric,10 Integer,150000 Numeric,16 Numeric,8
RF Expression "regression" Numeric,150000 Numeric,10 Numeric,10 Integer,150000 Numeric,16 Numeric,8
RF Expression "regression" Numeric,150000 Numeric,10 Numeric,10 Integer,150000 Numeric,16 Numeric,8
RF Expression "regression" Numeric,150000 Numeric,10 Numeric,10 Integer,150000 Numeric,16 Numeric,8
RF Expression "regression" Numeric,150000 Numeric,10 Numeric,10 Integer,150000 Numeric,16 Numeric,8
RF Expression "regression" Numeric,150000 Numeric,10 Numeric,10 Integer,150000 Numeric,16 Numeric,8
localImportance proximity ntree mtry forest coefs y test inbag
RF NULL NULL 10 2 List,11 NULL Integer,150000 NULL NULL
RF NULL NULL 10 2 List,11 NULL Integer,150000 NULL NULL
RF NULL NULL 10 2 List,11 NULL Integer,150000 NULL NULL
RF NULL NULL 10 2 List,11 NULL Integer,150000 NULL NULL
RF NULL NULL 10 2 List,11 NULL Integer,150000 NULL NULL
RF NULL NULL 10 2 List,11 NULL Integer,150000 NULL NULL
RF NULL NULL 10 2 List,11 NULL Integer,150000 NULL NULL
RF NULL NULL 10 2 List,11 NULL Integer,150000 NULL NULL
RF NULL NULL 10 2 List,11 NULL Integer,150000 NULL NULL
RF NULL NULL 10 2 List,11 NULL Integer,150000 NULL NULL
Có ai biết cách lưu trữ tất cả các đối tượng RF hoặc gọi chúng để thông tin được lưu trữ giống như một đối tượng RF đơn lẻ không? Cảm ơn bạn đã đề xuất.
hoạt động hoàn hảo, cảm ơn bạn rất nhiều! – screechOwl
Tại sao chúng ta không thể phát triển chúng một cách năng động? Đây có phải là giới hạn của R không? – wordsforthewise