Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/Error: error in neurons[[i]] %*% weights[[i]] : requires numeric/complex matrix/vector arguments - how to solve it?
Next
Answered
Helena Martin
  • 23
Helena Martin
Asked: May 18, 20222022-05-18T19:01:42+00:00 2022-05-18T19:01:42+00:00In: r

Error: error in neurons[[i]] %*% weights[[i]] : requires numeric/complex matrix/vector arguments – how to solve it?

  • 23

. 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!

regression
  • 2 2 Answers
  • 79 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    dttutoria Expert
    2022-06-22T08:44:14+00:00Added an answer on June 22, 2022 at 8:44 am

    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.

    m <- model.matrix(
    ~ Survived + Pclass + Sex + Age + SibSp + Parch + Fare + Embarked,
    data = d
    )
    head(m)
    library(neuralnet)
    r <- neuralnet(
    Survived ~ Pclass + Sexmale + Age + SibSp + Parch + Fare + EmbarkedC + EmbarkedQ + EmbarkedS,
    data=m, hidden=10, threshold=0.01
    )

     

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Léo Riviere
    2022-05-25T20:50:11+00:00Added an answer on May 25, 2022 at 8:50 pm

    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:

    1. Remove the variable
    2. Use integer instead if the variable is an ordinal factor.
    3. If the variable is character then transform it into factor, and then into a dummy variable.

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

    • 10
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.