. 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)
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:
Although I don’t know what you’re trying to accomplish here, please change this line.
This is how it looks (notice the extra brackets around your data).
Next, change the order in fit() as follows:
Finally, you can change prediction data as shown below (again, take a look at the extra square brackets).
The code will then run.