• Register
0 votes
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?

7.5k points

Please log in or register to answer this question.

1 Answer

0 votes

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

0 votes
1 answer 15 views
15 views
Problem: Does anyone know the solution : Error in one %*% x : requires numeric/complex matrix/vector arguments?
asked Jun 18 Aurelia Maja 78.4k points
0 votes
1 answer 17 views
17 views
Problem: Requires numeric/complex matrix/vector arguments.
asked Jun 30 Priscilla Gurpreet 74.7k points
0 votes
1 answer 1.7k views
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 ?
asked Nov 22, 2019 peterlaw 6.9k points
0 votes
1 answer 100 views
100 views
Problem: Hey everyone, any Help: cholmod error 'x and/or y have wrong dimensions' at file ../matrixops/cholmod_sdmult.c, line 90
asked Mar 13 Wafa Abu Yousef 6.1k points
0 votes
1 answer 1.2k views
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?
asked Dec 11, 2019 alecxe 7.5k points
0 votes
1 answer 2.8k views
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
asked Nov 13, 2019 peterlaw 6.9k points
0 votes
1 answer 6 views
6 views
Problem: Invalid prediction for "rpart" object?
asked 6 days ago Mezbah 130k points
0 votes
1 answer 6 views
6 views
Problem: Scatter plot in r with regression line
asked Jul 26 Sawyer Parviz 168k points
0 votes
1 answer 8 views
8 views
Problem: I'm unable to identify the complication and need assistance : Difference between multiple r squared and adjusted r squared
asked Jun 23 asha 121k points
0 votes
1 answer 52 views
52 views
Problem: What am I supposed to do here? >Coefficients: (1 not defined because of singularities).
asked May 15 Florina Gulnar 106k points