klearn.preprocessing.PolynomialFeatures学习
多项式特征处理
class sklearn.preprocessing.PolynomialFeatures(degree=2, interaction_only=False, include_bias=True)
参数:
degree
interaction_only 默认为False
include_bias 表示生成0指数项
| Parameters: |
|
|---|
案例1:
>>> import numpy as np
>>> from sklearn.preprocessing import PolynomialFeatures
>>> X = np.arange(6).reshape(3, 2)
>>> X
array([[0, 1],
[2, 3],
[4, 5]])
>>> poly = PolynomialFeatures(2)
>>> poly.fit_transform(X)
array([[ 1., 0., 1., 0., 0., 1.],
[ 1., 2., 3., 4., 6., 9.],
[ 1., 4., 5., 16., 20., 25.]])

interaction_only=True
>>> X = np.arange(9).reshape(3, 3)
>>> X
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
>>> poly = PolynomialFeatures(degree=3, interaction_only=True)
>>> poly.fit_transform(X)
array([[ 1., 0., 1., 2., 0., 0., 2., 0.],
[ 1., 3., 4., 5., 12., 15., 20., 60.],
[ 1., 6., 7., 8., 42., 48., 56., 336.]])

方法:
fit(X[, y]) Compute number of output features.
fit_transform(X[, y]) Fit to data, then transform it.
get_feature_names([input_features]) Return feature names for output features
get_params([deep]) Get parameters for this estimator.
set_params(**params) Set the parameters of this estimator.
transform(X) Transform data to polynomial features
klearn.preprocessing.PolynomialFeatures学习的更多相关文章
- 2.2sklearn.preprocessing.PolynomialFeatures生成交叉特征
sklearn.preprocessing.PolynomialFeatures原文 多项式生成函数:sklearn.preprocessing.PolynomialFeatures(degree=2 ...
- Scikit-Learn模块学习笔记——数据预处理模块preprocessing
preprocessing 模块提供了数据预处理函数和预处理类,预处理类主要是为了方便添加到 pipeline 过程中. 数据标准化 标准化预处理函数: preprocessing.scale(X, ...
- sklearn学习笔记之简单线性回归
简单线性回归 线性回归是数据挖掘中的基础算法之一,从某种意义上来说,在学习函数的时候已经开始接触线性回归了,只不过那时候并没有涉及到误差项.线性回归的思想其实就是解一组方程,得到回归函数,不过在出现误 ...
- sklearn学习总结(超全面)
https://blog.csdn.net/fuqiuai/article/details/79495865 前言sklearn想必不用我多介绍了,一句话,她是机器学习领域中最知名的python模块之 ...
- sklearn 的 PolynomialFeatures 的用法
官方文档:http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.PolynomialFeatures.html ...
- python中常用的九种数据预处理方法分享
Spyder Ctrl + 4/5: 块注释/块反注释 本文总结的是我们大家在python中常见的数据预处理方法,以下通过sklearn的preprocessing模块来介绍; 1. 标准化(St ...
- 使用sklearn进行数据挖掘
sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频) https://study.163.com/course/introduction.htm?courseId=1005269003& ...
- 人工智能(Machine Learning)—— 机器学习
https://blog.csdn.net/luyao_cxy/article/details/82383091 转载:https://blog.csdn.net/qq_27297393/articl ...
- scikit-learn API
scikit-learn API 这是scikit-learn的类和函数参考.有关详细信息,请参阅完整的用户指南,因为类和功能原始规格可能不足以提供有关其用途的完整指南. sklearn.base:基 ...
随机推荐
- Python的GIL机制与多线程编程
GIL 全称global interpreter lock 全局解释锁 gil使得python同一个时刻只有一个线程在一个cpu上执行字节码,并且无法将多个线程映射到多个cpu上,即不能发挥多个cpu ...
- 软工+C(3): 超链接
// 上一篇:分数和checklist // 下一篇:Alpha/Beta换人 注:平常看文章,总有能和构建之法,软件工程相关的链接,增量记录,也可以通过在其他人博客的交流中使用相关的超链接,在使用中 ...
- WebViewClient 与 WebChromeClient
WebViewClient帮助WebView处理各种通知和请求事件的,我们可以称他为WebView的“内政大臣”.常用的shouldOverrideUrlLoading就是该类的一个方法,比如: on ...
- luogu P1744 采购特价商品
实话说我本来想找SPFA的题,结果我硬生生的把这道题做成了Floyd 先来看题,我们会发现如果把他所给的变量都输入,那么会发现用Floyd的解法,输入占了main函数的一半长度... 题目分为两步走: ...
- python学习日记(OOP——@property)
在绑定属性时,如果我们直接把属性暴露出去,虽然写起来很简单,但是,没办法检查参数,导致可以把成绩随便改: s = Student() s.score = 9999 这显然不合逻辑.为了限制score的 ...
- GiBbook实用配置以及插件
GitBook可以在您的计算机上用于构建本地书籍,,可以本地预览 安装gitbook 环境要求: 安装GitBook,您的系统需要安装NodeJS(推荐v4.0.0及以上版本) NodeJS下载地址 ...
- golang与python多线程的并发速度
一.golang的代码 package main import ( "fmt" "time" ) func Text_goroute(a int, b int) ...
- JS学习笔记Day15
一.ES5及ES6 (一)严格模式 (二)bind/call/apply(改变上下文this指向,都是函数对象的方法) 1.bind:返回值是一个函数 2.call:返回值是一个对象 3.apply: ...
- openstack项目【day23】:keystone组件网关协议
本节内容 一 静态页面和动态页面 二 什么是web server 三 什么是网关协议 3.1 引子 3.2 网关协议 四 网关协议CGI.FastCGI.WSGI.UWSGI 五 网关协议与keyst ...
- phpstorm快捷键大全
前言:这段时间换了编辑器,所以挺多命令也改变了 转载来自:https://www.jianshu.com/p/ffb24d61000d?utm_campaign=maleskine&utm_c ...