Adding back the list... It works for me:
In [15]: from sklearn.preprocessing import OneHotEncoder In [16]: enc = OneHotEncoder() In [17]: enc.fit([[0, 0, 3], [1, 1, 0], [0, 2, 1], [1, 0, 2]]) Out[17]: OneHotEncoder(categorical_features='all', dtype=<type 'float'>, handle_unknown='error', n_values='auto', sparse=True) In [18]: enc.transform([[0, 1, 1]]).toarray() Out[18]: array([[ 1., 0., 0., 1., 0., 0., 1., 0., 0.]]) In [19]: import cPickle as pickle In [20]: s = pickle.dumps(enc) In [21]: enc_deser = pickle.loads(s) In [22]: enc_deser.transform([[0, 1, 1]]).toarray() Out[22]: array([[ 1., 0., 0., 1., 0., 0., 1., 0., 0.]]) Perhaps provide the stack trace and example code to reproduce if possible? On Wed, Nov 18, 2015 at 9:53 AM, Startup Hire <blrstartuph...@gmail.com> wrote: > Hi Nick, > > Quick doubt: > > I saved the OneHotEncoder "fit" function ie in > b=enc.fit(test) , I saved b > > Then, I used b.transform(newdata) , but the error > now comes because of # of rows in test and newdata being different > > Am I doing something wrong in saving the OneHotEncoder and reusing it? > > Regards, > Sanant > > On Wed, Nov 18, 2015 at 11:24 AM, Nick Pentreath <nick.pentre...@gmail.com > > wrote: > >> No problem - hope you solve your issue :) >> >> — >> Sent from Mailbox <https://www.dropbox.com/mailbox> >> >> >> On Wed, Nov 18, 2015 at 5:47 AM, Startup Hire <blrstartuph...@gmail.com> >> wrote: >> >>> Thanks for your explanation! >>> >>> >> >
------------------------------------------------------------------------------
_______________________________________________ Scikit-learn-general mailing list Scikit-learn-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/scikit-learn-general