I Kernel Ridge Regression in R.Nicht Conformable Arrays, wenn in R Matrixmultiplikation Doing
Die Formel umzusetzen versuche ist:
alpha <- ((lambda.I + K)^(-1)) * y
Lambda = 0,1. I = Einheitsmatrix die gleiche Größe wie K. y ist ein Merkmalsvektor, der die gleiche Anzahl von Zeilen wie K. hat
Also habe ich versucht, dies in R:
I <- diag(nrow(df_matrix)
lambda <- 0.1
alpha <- (lambda * I + df_matrix)^(-1) * df_vector
bekomme ich folgende Fehler
Error in (0.1 * I + df_matrix)^(-1) * df_vector : non-conformable arrays
hier einige Informationen über meine Dataset
> nrow(df_matrix)
[1] 8222
> ncol(df_matrix)
[1] 8222
> nrow(df_vector)
[1] 8222
> nrow(I)
[1] 8222
> ncol(I)
[1] 8222
> class(df_matrix)
[1] "matrix"
> class(df_vector)
[1] "matrix"
Die Syntax zum Invertieren einer Matrix in R ist nicht "^ (- 1)". Und '*' ist keine Matrixmultiplikation in R. – Roland
Was ist ncol (df_vector)? Wenn Sie davon ausgehen, dass es 8222 oder 1 ist, scheint der Code zu funktionieren – vasanthcullen