class
sklearn.feature_extraction.
DictVectorizer
(
dtype=<class ‘numpy.float64’>
,
separator=’=’
,
sparse=True
,
sort=True
)
Transforms
lists
of feature-value mappings to vectors.
This transformer
turns lists of mappings (dict-like objects
) of feature names to feature values into Numpy
arrays
or scipy.
sparse matrices(稀疏矩阵)
for use with scikit-learn estimators.
When feature values are strings, this transformer will do a binary one-hot (aka one-of-K) coding: one boolean-valued feature is constructed for each of the possible string values that the feature can take on. For instance, a feature “f” that can take on the values “ham” and “spam” will become two features in the output, one signifying “f=ham”, the other “f=spam”.
However, note that this transformer will only do a binary one-hot encoding when feature values are of type string. If categorical features are represented as numeric values such as int, the DictVectorizer can be followed by OneHotEncoder to complete binary one-hot encoding.
Features that do not occur in a sample (mapping) will have a zero value in the resulting array/matrix.
Parameters:
dtype
: callable, optional
The type of feature values. Passed to Numpy array/scipy.sparse matrix constructors as the dtype argument.
separator
: string, optional
Separator string used when constructing new features for one-hot coding.
sparse
: boolean, optional.
Whether transform should produce scipy.sparse matrices. True by default.
sort
: boolean, optional.
Whether
feature_names_
and
vocabulary_
should be sorted when fitting. True by default.
Attributes:
vocabulary_
: dict
A dictionary mapping feature names to feature indices.
feature_names_
: list
A list of length n_features containing the feature names (e.g., “f=ham” and “f=spam”).
微信关注我们
原文链接:https://yq.aliyun.com/articles/414614
转载内容版权归作者及来源网站所有!
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
相关文章
发表评论
资源下载
更多资源Mario,低调大师唯一一个Java游戏作品
马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。
Apache Tomcat7、8、9(Java Web服务器)
Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache、Sun 和其他一些公司及个人共同开发而成。因为Tomcat 技术先进、性能稳定,而且免费,因而深受Java 爱好者的喜爱并得到了部分软件开发商的认可,成为目前比较流行的Web 应用服务器。
Java Development Kit(Java开发工具)
JDK是 Java 语言的软件开发工具包,主要用于移动设备、嵌入式设备上的java应用程序。JDK是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和JAVA工具。
Sublime Text 一个代码编辑器
Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。