-
-
Notifications
You must be signed in to change notification settings - Fork 26.4k
Closed
Description
I was recently trying to do just a very simple linear regression on x vs. y -- I got this error message:
IndexError: tuple index out of range
I wasted 3 minutes trying to figure out if my x and y vectors didn't have the same lengths (they did), whether the problem was that they were lists, not numpy arrays (they were). Then I found the culprit, through stackoverflow:
http://stackoverflow.com/questions/27107057/sklearn-linear-regression-python
The trick is to replace:
regr.fit(x,y)
With:
regr.fit(x[:,np.newaxis],y)
I know this is only a small inconvenience for me, but I think this needs to be addressed for the sake of usability. This provides an unnecessarily difficult entry barrier to new users.
A related thought/comment: Do the inputs have to be numpy arrays? Why not try to salvage the input if the user passes lists?
Metadata
Metadata
Assignees
Labels
No labels