PolynomialFeatures使用

PolynomialFeatures

sklearn.preprocessing.PolynomialFeatures 用法
sklearn中数据预处理过程中的多项式特征构造工具包。
eg:[x1,x2] -> [1,x1,x2,x12,x1*x2,x22]输入一个二维样本。产生二阶多项式特征。

1.参数理解:(一共只有3个参数)

  • degree : integer
    The degree of the polynomial features. Default = 2.
    多项式的阶数,一般默认是2。
  • interaction_only : boolean, default = False
    If true, only interaction features are produced: features that are products of at most degree distinct input features (so not x[1] ** 2, x[0] * x[2] ** 3, etc.).
    如果值为true(默认是false),则会产生相互影响的特征集。
  • include_bias : boolean
    If True (default), then include a bias column, the feature in which all polynomial powers are zero (i.e. a column of ones - acts as an intercept term in a linear model).
    是否包含偏差列

2.属性

  • powers_ : array, shape (n_input_features, n_output_features)
    powers_[i, j] is the exponent of the jth input in the ith output.
  • n_input_features_ : int
    The total number of input features.
    输入特征的个数
  • n_output_features_ : int
    The total number of polynomial output features. The number of output features is computed by iterating over all suitably sized combinations of input features.
    输出多项式的特征个数。它的计算是通过遍历所有的适当大小的输入特征组合。

3.方法

  1. fit(X, y=None)
    Compute number of output features.
    计算输出特征的个数
  2. fit_transform(X, y=None, **fit_params)
    Fit to data, then transform it.
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 有急事,先交作业,急事处理后补充 补充日记 今天的心动摇了,没有按赖得住。孩子不知不觉以快七岁了...
    李键成阅读 1,371评论 0 3
  • 久居 斗室或忙于工作,每每都会感到心灵上的压力,总是想着放松一下自己,而城市太喧嚣,倦意难遣,去哪里寻找宁静?寻找...
    tangjianguo阅读 3,126评论 0 0
  • 读来并没有多少高潮和起伏,但就是能看得下去。据说很多人会3个通宵读完,我看了差不多3个礼拜。 1.身不由己,即使是...
    夏言花信阅读 2,924评论 0 0
  • 文/风相雨 做一个孩子常怀善意留一颗质朴的心和一双纯粹的眼睛蕴着不坠的童真 做一个孩子以孩子的视角拥抱清晨、蓝天夕...
    风相雨阅读 2,600评论 1 3