fit expects 2-dimensional input, whereas X[:, 0] is one dimensional. You
can either reshape it manually:
regr.fit(x_train[:, 0].reshape((x_train.shape[0], 1)), x_train[:, 1])
or use slices to select continuous range of columns:
regr.fit(x_train[:, :1], x_train[:, 1])
What exception tells you is that x_train is of wrong shape. If x_train was
2-dimensional, it's shape would have a 2nd element (with index 1).
On Wed, Feb 11, 2015 at 9:26 PM, Pagliari, Roberto <rpagli...@appcomsci.com>
wrote:
> I’m trying to make a linear regression with one independent variable and
> one or more dependent variables.
>
>
>
> That does not seem to work. Is that a limitation of regression function?
>
>
>
> regr.fit(x_train[:, 0], x_train[:, 1])
>
>
>
> File
> "/usr/local/lib/python2.7/dist-packages/sklearn/linear_model/base.py", line
> 355, in fit
>
> X, y, self.fit_intercept, self.normalize, self.copy_X)
>
> File
> "/usr/local/lib/python2.7/dist-packages/sklearn/linear_model/base.py", line
> 104, in center_data
>
> X_std = np.ones(X.shape[1])
>
> IndexError: tuple index out of range
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming. The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is
> your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Scikit-learn-general mailing list
> Scikit-learn-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general