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

6 5 3
7,540 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.

9 7 4
38,600 points

Related questions

0 votes
1 answer 1.4K views
1.4K 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 925 views
925 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 17 views
17 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 2.2K views
2.2K 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
1 vote
1 answer 954 views
954 views
Problem : I am learning R. I am trying to make the subset of my data frame in the R which is based on one or the other value available in my column of the factors but because of some unknown reason to me I am unable to use | operator with the factor values. If I try to ... != "c" as it will not work. I am stuck with above error from past two days. Please guide me in fixing above R error for me.
asked May 12, 2020 Martin K 6.6k points
0 votes
1 answer 2.5K views
2.5K views
Problem : I have been facing below error message and traceback: Error in FUN(X[[i]], ...) : only defined on the data frame with all numeric variables 5 stop("only defined on the data frame with all numeric variables") 4 FUN(X[[i]], ...) 3 lapply(args, ... .numeric(data[good,]) But now I get the different error message back as below : "Error: (list) object cannot be coerced to type 'double'"
asked Dec 16, 2019 alecxe 7.5k points
0 votes
1 answer 31 views
31 views
Problem: Please help me how can I solve it? Factor variables may not contain noninteger values
asked Mar 18 Ifra 24.4k points
0 votes
1 answer 5 views
5 views
Problem: I need help in solving this error: Error in cbind2(1, newx) %*% nbeta : invalid class 'na' to dup_mmatrix_as_dgematrix
asked Mar 14 Wafa Abu Yousef 6.1k points
1 vote
1 answer 1.6K views
1.6K views
Problem : I want to use the glmnet package on a dataset. I am trying to use cv.glmnet() to get the lambda value for the glmnet(). Please find below the dataset and error message: > head(t2) X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 1 ... in evaluating the argument 'x' in selecting a method for function 't': Error: invalid class 'NA' to dup_mMatrix_as_dgeMatrix Any suggestions regarding the solution?
asked Dec 14, 2019 alecxe 7.5k points
0 votes
1 answer 1.6K views
1.6K views
Problem : When ever i use the predict glmnet function i get the below mentioned error error in cbind2(1, newx) %*% nbeta : not-yet-implemented method for <data.frame> %*% <dgcmatrix>
asked Nov 12, 2019 peterlaw 6.9k points