scikit-learn:4.2. Feature extraction(特征提取,不是特征选择)

http://scikit-learn.org/stable/modules/feature_extraction.html

带病在网吧里。。。。。。写,求支持。。。


1、首先澄清两个概念:特征提取和特征选择( 

Feature extraction is very different from Feature selection

)。

the former consists in transforming arbitrary data, such as text or images, into numerical features usable for machine learning. The latter is a machine learning technique applied on these features(从已经提取的特征中选择更好的特征).


下面分为四大部分来讲,主要还是4、text feature extraction

2、loading features form dicts

class DictVectorizer。举个例子就好:

>>> measurements = [
...     {
  'city': 'Dubai', 'temperature': 33.},
...     {
  'city': 'London', 'temperature': 12.},
...     {
  'city': 'San Fransisco', 'temperature': 18.},
... ]
>>> from sklearn.feature_extraction import DictVectorizer
>>> vec = DictVectorizer()
>>> vec.fit_transform(measurements).toarray()
array([[  1.,   0.,   0.,  33.],
       [  0.,   1.,   0.,  12.],
       [  0.,   0.,   1.,  18.]])
>>> vec.get_feature_names()
['city=Dubai', 'city=London', 'city=San Fransisco', 'temperature']


class 
  • 16
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值