# Error in neurons[[i]] %*% weights[[i]] : requires numeric/complex matrix/vector arguments

1.7k views

## Problem :

I am learning to work with neural networks in R. As a learning tutorial I am using the following problem over at Kaggle:

https://www.kaggle.com/c/titanic

This problem is specifically designed for people who want to learn and please note there is no reward tied to it.

I have started with a simple logistic regression, My training data looks like the following

Column : Row

`- survived: 1`
`- pclass:   3`
`- sex:      male`
`- age:      22.0`
`- sibsp:    1`
`- parch:    0`
`- ticket:   PC 17601`
`- fare:     7.25`
`- cabin:    C85`
`- embarked: S`

And my starting R code looks like following code:

`> net <- neuralnet(survived ~ pclass + sex + age + sibsp + parch + ticket + fare + cabin + embarked, train, hidden=10, threshold=0.01)`

But whenever I try to run this line of code I get the following error:

`Error in neurons[[i]] %*% weights[[i]] : `
`requires numeric/complex matrix/vector arguments`

Can anyone help in resolving my issue?

## Solution :

The Error Message "Requires numeric/complex matrix/vector arguments" occurs when you have either factor or character variables in your data.

There are three ways to solve your problem:

1. Try Deleting the variable

2.  If your variable is the ordered factor then use integer instead.

3.  If your variable is character, then transform it into factor and then into dummy variable.

You can use the model.matrix() mentioned above or class.ind() function from nnet package to transfer the factor into dummy variable.

38.6k points

## Related questions

15 views
Problem: Does anyone know the solution : Error in one %*% x : requires numeric/complex matrix/vector arguments?
17 views
Problem: Requires numeric/complex matrix/vector arguments.
1.7k views
Problem : Suppose I have data.frame a And I am using following code m.fit <- lm(col2 ~ col3 * col4, na.action = na.exclude) Here the col2 has some NA values And col3,col4 have values less than 1. I am getting following error: Error in lm.fit ... because of the NAs. Problem with this warning is interpreted by every google results is pointing towards the NA values. Have I misinterpreted the error ?
100 views
Problem: Hey everyone, any Help: cholmod error 'x and/or y have wrong dimensions' at file ../matrixops/cholmod_sdmult.c, line 90
1.2k views
Problem : I want to use the neural net for predictions. I am trying to create some X as follows : x <- cbind(seq(1, 50, 1), seq(51, 100, 1)) I am trying to create some Y as follows : y <- x[,1]*x[,2] Give them the names as follows colnames(x) ... =0.01) error in terms.formula(formula) : '.' in formula and no 'data' argument Does anybody have any idea regarding the error I am facing? Any solution?
2.8k views
Problem : I am trying to predict probabilities in a dataset by using glmnet but facing following issue cholmod error 'x and/or y have wrong dimensions' at file ../matrixops/cholmod_sdmult.c, line 90
6 views
Problem: Invalid prediction for "rpart" object?