Code Monkey home page Code Monkey logo

dsc-1-11-04-dealing-with-categorical-variables's Issues

errors on sklearn labelbinarizer

screen shot 2018-12-02 at 5 14 20 pm

I did not change anything.

TypeErrorTraceback (most recent call last)
in ()
2
3 lb = LabelBinarizer()
----> 4 origin_dummies = lb.fit_transform(cat_origin)
5 # you need to convert this back to a dataframe
6 origin_dum_df = pd.DataFrame(origin_dummies,columns=lb.classes_)

/opt/conda/envs/learn-env/lib/python3.6/site-packages/sklearn/preprocessing/label.py in fit_transform(self, y)
434 Shape will be [n_samples, 1] for binary problems.
435 """
--> 436 return self.fit(y).transform(y)
437
438 def transform(self, y):

/opt/conda/envs/learn-env/lib/python3.6/site-packages/sklearn/preprocessing/label.py in transform(self, y)
465 pos_label=self.pos_label,
466 neg_label=self.neg_label,
--> 467 sparse_output=self.sparse_output)
468
469 def inverse_transform(self, Y, threshold=None):

/opt/conda/envs/learn-env/lib/python3.6/site-packages/sklearn/preprocessing/label.py in label_binarize(y, classes, neg_label, pos_label, sparse_output)
579 # XXX Workaround that will be removed when list of list format is
580 # dropped
--> 581 y = check_array(y, accept_sparse='csr', ensure_2d=False, dtype=None)
582 else:
583 if _num_samples(y) == 0:

/opt/conda/envs/learn-env/lib/python3.6/site-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
478 # DataFrame), and store them. If not, store None.
479 dtypes_orig = None
--> 480 if hasattr(array, "dtypes") and len(array.dtypes):
481 dtypes_orig = np.array(array.dtypes)
482

TypeError: object of type 'CategoricalDtype' has no len()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.