Thanks a lot Artem :)
It worked!
Shalu
On Mon, Feb 16, 2015 at 2:05 PM, Artem <barmaley....@gmail.com> wrote:
> X needs to be a matrix of shape (n_samples, n_features), not a vector. You
> need to reshape it into the matrix by doing
>
> X_train = X_train.reshape( (len(X_train), 1) )
>
> On Mon, Feb 16, 2015 at 4:01 PM, shalu jhanwar <shalu.jhanwa...@gmail.com>
> wrote:
>
>> Hi Scikit fans,
>>
>> I am facing following error while performing classification with *single
>> feature* only:
>>
>> reg = linear_model.LogisticRegression()
>> *scores.append(reg.fit(X_train, y_train).score(X_test, y_test))*
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File
>> "/software/so/el6.3/PythonPackages-2.7.6/lib/python2.7/site-packages/sklearn/svm/base.py",
>> line 676, in fit
>> (X.shape[0], y.shape[0]))
>> *ValueError: X and y have incompatible shapes.*
>> X has 1 samples, but y has 1692.
>>
>> My variables look like:
>>
>> >>>X_train
>> array([ 1., 1., 1., ..., 1., 1., 1.])
>> >>>X_train.shape
>> (1692,)
>> >>>y_train
>> array([ 0., 0., 1., ..., 0., 1., 1.])
>> >>>y_train.shape
>> y_train.shape
>> (1692,)
>>
>>
>> Can someone help me removing this error?
>>
>> Thanks!
>> Shalu
>>
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Scikit-learn-general mailing list
>> Scikit-learn-general@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>>
>>
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Scikit-learn-general mailing list
> Scikit-learn-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general