当前位置:网站首页>机器学习-特征映射方法
机器学习-特征映射方法
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
边栏推荐
- The latest real software test interview questions are shared. Are you afraid that you will not be able to enter the big factory after collecting them?
- Mysql查看慢查询日志
- 程序员的七夕浪漫时刻
- Cholesterol-PEG-Acid,胆固醇-聚乙二醇-羧基保持在干燥、低温环境下
- 基于飞腾平台的嵌入式解决方案案例集 1.0 正式发布!
- 在软件测试行业近20年的我,再来和大家谈谈今日的软件测试
- 最近公共祖先(LCA)学习笔记 | P3379 【模板】最近公共祖先(LCA)题解
- resubmit 渐进式防重复提交框架简介
- 记一次mysql查询慢的优化历程
- 停止使用 Storyboards 和 Interface Builder
猜你喜欢

CWE4.8:2022年危害最大的25种软件安全问题

# DWD层及DIM层构建## ,220801 ,

程序员的七夕浪漫时刻

Test | ali internship 90 days in life: from the perspective of interns, talk about personal growth

测试人生 | 阿里实习 90 天:从实习生的视角谈谈个人成长

我为什么又能面试一次就拿到offer

centos7安装mysql8

FastCorrect:语音识别快速纠错模型丨RTC Dev Meetup

Cholesterol-PEG-Acid,胆固醇-聚乙二醇-羧基保持在干燥、低温环境下

别再到处乱放配置文件了!我司使用 7 年的这套解决方案,稳的一秕
随机推荐
【代码扫描修复】MD5加密弱HASH漏洞
The latest real software test interview questions are shared. Are you afraid that you will not be able to enter the big factory after collecting them?
No-code development platform form styling steps introductory course
十二、form表单的提交
markdown语法
openssl源码下载
程序员常说的“左手锟斤拷,右手烫烫烫”是怎么回事?
msys2下载地址
qt静态编译出现Project ERROR: Library ‘odbc‘ is not defined
js基础知识整理之 —— 五种输出方式
js基础知识整理之 —— 变量和数据类型
服务间歇性停顿问题优化|得物技术
vant-swipe自适应图片高度+图片预览
CAS:1445723-73-8,DSPE-PEG-NHS,磷脂-聚乙二醇-活性酯两亲性脂质PEG共轭物
记一次mysql查询慢的优化历程
js基础知识整理之 —— 字符串
mysql查询表中重复记录
resubmit 渐进式防重复提交框架简介
R语言自学 1 - 向量
思源笔记 本地存储无使用第三方同步盘,突然打不开文件。