. Advertisement .

..3..

. Advertisement .

..4..

Hi developer experts, I have a small but frustrating use case, and so far, I couldn’t get my head around this problem & ideal solution. I am running my command and facing one problem with the error in neurons[[i]] %*% weights[[i]] : requires numeric/complex matrix/vector arguments. Below is the command I used:

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

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

When I run it, I get the following error:

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

I am looking forward to gaining some knowledge from all experts. Thank you, guys!

The cause:You can eliminate the name, ticket, cabin, and passengerId variables because they have too many values to be relevant (at least in your initial model).Solution:If it makes more sense, you might also want to convert some of the numerical variables (like class) to factors. The

`model.matrix`

function can be used to convert all qualitative variables (factors) to binary (“dummy”) variables because`neuralnet`

only works with quantitative variables.When you have character or factor variables in your data, an error message “requis numeric/complex matrix/vector arguments” will occur.

This problem can be solved in three ways:

To convert a factor into a dummy variable, you can use either model.matrix() or class.ind() functions from the nnet package.