R rfe Funktion “caret” Paketfehler: Es sollte die gleiche Anzahl von Samples in x und y @ gebe
Wie ich versuche das rfe-Beispiel aus dem "caret" -Paket ausHie, Ich habe diesen Fehler immer wieder erhalten
Error in rfe.default(d[1:2901, ], c(1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, :
there should be the same number of samples in x and y
Diese Fragewurde gefragt aber seine Lösung trifft in diesem Fall nicht zu.
Hier ist der Code:
set.seed(7)
# load the library
library(mlbench)
library(caret)
# load the data
d <- read.table("d.dat")
# define the control using a random forest selection function
control <- rfeControl(functions=rfFuncs, method="cv", number=10)
# run the RFE algorithm
results <- rfe(d[1:2901, ], c(1,1,1,1, 1, 1,2,2,2, 3 ,3,3,4, 4, 4), sizes=c(1:2901), rfeControl=control)
# summarize the results
print(results)
Das Dataset besteht aus einem Datenrahmen mit 2901 Zeilen (Features) und 15 Spalten. Der Vektor c (1,1,1,1,1,1,2,2,2,3,3,4,4) ist der Prädiktor für die Merkmale.
Welcher Parameter ist falsch eingestellt?