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/Recommendation for the valueerror: only 2 non-keyword arguments accepted error
Next
Answered
Kylie Garcia
  • 13
Kylie Garcia
Asked: May 18, 20222022-05-18T18:13:36+00:00 2022-05-18T18:13:36+00:00In: python

Recommendation for the valueerror: only 2 non-keyword arguments accepted error

  • 13

. Advertisement .

..3..

. Advertisement .

..4..

I get the error message:

ValueError: only 2 non-keyword arguments accepted

Has anyone ever faced this problem? How to troubleshoot the “valueerror: only 2 non-keyword arguments accepted.” The problem appears when I try to operate the following program:

from sklearn.linear_model import LinearRegression
  import numpy as np
 
  trainingData = np.array([[861, 16012018], [860, 12012018], [859, 9012018], [858, 5012018], [857, 2012018], [856, 29122017], [855, 26122017], [854, 22122017], [853, 19122017]])
  trainingScores = np.array([11,18,23,33,34,6],[10,19,21,33,34,1], [14,18,22,23,31,6],[16,22,29,31,33,10],[21,24,27,30,31,6],[1,14,15,20,27,7],[1,9,10,11,15,8],[2,9,27,31,35,1],[7,13,18,22,33,2])
 
  clf = LinearRegression(fit_intercept=True)
  clf.fit(trainingScores,trainingData)
 
  predictionData = np.array([862, 19012018 ])
  x=clf.predict(predictionData)
  print(x)

valueerror
  • 2 2 Answers
  • 86 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    dttutoria Expert
    2022-06-21T10:42:03+00:00Added an answer on June 21, 2022 at 10:42 am

    The cause: The matrix construction format was not distinguished clearly, which was the cause of the valueerror: only 2 non-keyword arguments accepted.

    Solution: You are performing a linear regression in ML, it needs to consider replacing this line with:

    trainingScores = np.array(
    [11,18,23,33,34,6],
    [10,19,21,33,34,1],
    [14,18,22,23,31,6],
    [16,22,29,31,33,10],
    [21,24,27,30,31,6],
    [1,14,15,20,27,7],
    [1,9,10,11,15,8],
    [2,9,27,31,35,1],
    [7,13,18,22,33,2]
    )
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Raphaël Martins
    2022-05-25T20:44:24+00:00Added an answer on May 25, 2022 at 8:44 pm

    Although I don’t know what you’re trying to accomplish here, please change this line.

    trainingScores = np.array([11,18,23,33,34,6],[10,19,21,33,34,1], [14,18,22,23,31,6],[16,22,29,31,33,10],[21,24,27,30,31,6],[1,14,15,20,27,7],[1,9,10,11,15,8],[2,9,27,31,35,1],[7,13,18,22,33,2])

    This is how it looks (notice the extra brackets around your data).

    trainingScores = np.array([[11,18,23,33,34,6],[10,19,21,33,34,1], [14,18,22,23,31,6],[16,22,29,31,33,10],[21,24,27,30,31,6],[1,14,15,20,27,7],[1,9,10,11,15,8],[2,9,27,31,35,1],[7,13,18,22,33,2]])

    Next, change the order in fit() as follows:

    clf.fit(trainingData,trainingScores)

    Finally, you can change prediction data as shown below (again, take a look at the extra square brackets).

    predictionData = np.array([[862, 19012018]])

    The code will then run.

    • 17
    • 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.