当前位置:网站首页>机器学习-特征映射方法
机器学习-特征映射方法
2022-08-02 22:55:00 【旅途中的宽~】
在进行正则化逻辑回归的时候,需要用到特征映射的方法:将一个二维特征(x1, x2)根据自己的需要映射到高维。
如下图所示的例子:
# 这里x,y是np数组的形式,as_ndarray默认为false,这是作者定义的函数
def feature_mapping(x, y, power, as_ndarray=False):
data = {
"F{}{}".format(i - p, p): np.power(x, i - p) * np.power(y, p)
for i in np.arange(power + 1)
for p in np.arange(i + 1)
}
if as_ndarray:
return np.array(pd.DataFrame(data))
else:
return pd.DataFrame(data)
我们的结果展示为:
F00 F10 F01 ... F24 F15 F06
0 1.0 0.051267 0.699560 ... 6.294709e-04 8.589398e-03 1.172060e-01
1 1.0 -0.092742 0.684940 ... 1.893054e-03 -1.398103e-02 1.032560e-01
2 1.0 -0.213710 0.692250 ... 1.048821e-02 -3.397345e-02 1.100469e-01
3 1.0 -0.375000 0.502190 ... 8.944062e-03 -1.197765e-02 1.604015e-02
4 1.0 -0.513250 0.465640 ... 1.238395e-02 -1.123519e-02 1.019299e-02
.. ... ... ... ... ... ... ...
113 1.0 -0.720620 0.538740 ... 4.374511e-02 -3.270412e-02 2.444980e-02
114 1.0 -0.593890 0.494880 ... 2.115493e-02 -1.762810e-02 1.468924e-02
115 1.0 -0.484450 0.999270 ... 2.340073e-01 -4.826843e-01 9.956280e-01
116 1.0 -0.006336 0.999270 ... 4.003286e-05 -6.313306e-03 9.956280e-01
117 1.0 0.632650 -0.030612 ... 3.514745e-07 -1.700678e-08 8.229060e-10
边栏推荐
- 基于STM32的FLASH读写实验含代码(HAL库)
- resubmit 渐进式防重复提交框架简介
- 辅助脚本开发之旅
- I have been in the software testing industry for nearly 20 years, let me talk to you about today's software testing
- The CTF command execution subject their thinking
- vscode 自定义快捷键——设置eslint
- 同一份数据,Redis为什么要存两次?
- Directing a non-relational database introduction and deployment
- 数据库主键一定要自增吗?有哪些场景不建议自增?
- 如何使用vlookup+excel数组公式 完成逆向查找?
猜你喜欢

一个很少见但很有用的SQL功能

无代码开发平台表单样式设置步骤入门课程

Technology Sharing | How to do assertion verification for xml format in interface automation testing?

Image recognition from zero to write DNF script key points

vscode 自定义快捷键——设置eslint

最近公共祖先(LCA)学习笔记 | P3379 【模板】最近公共祖先(LCA)题解

Let's talk about the charm of code language

如何使用vlookup+excel数组公式 完成逆向查找?

redis的学习笔记

学习Autodock分子对接
随机推荐
无代码开发平台表单样式设置步骤入门课程
markdown语法
Technology Sharing | How to do assertion verification for xml format in interface automation testing?
严格反馈非线性系统基于事件触发的自抗扰预设有限时间跟踪控制
Jmeter secondary development to realize rsa encryption
CAS:474922-22-0,DSPE-PEG-MAL,磷脂-聚乙二醇-马来酰亚胺科研试剂供应
DownMusic summary record
resubmit 渐进式防重复提交框架简介
2022中国眼博会,山东眼健康展,视力矫正仪器展,护眼产品展
WebShell 木马免杀过WAF
B站回应HR称用户是Loser:涉事面试官去年底已被劝退
我为什么又能面试一次就拿到offer
redis的学习笔记
别再到处乱放配置文件了!我司使用 7 年的这套解决方案,稳的一秕
漫画:怎么证明sleep不释放锁,而wait释放锁?
聚乙二醇衍生物4-Arm PEG-DSPE,四臂-聚乙二醇-磷脂
雷克萨斯lm的安全性如何?
js基础知识整理之 —— 五种输出方式
最近公共祖先(LCA)学习笔记 | P3379 【模板】最近公共祖先(LCA)题解
today‘s task