learn-co-curriculum / dsc-1-11-04-dealing-with-categorical-variables Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
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()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.