博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
经典机器学习算法系列7-svd
阅读量:4320 次
发布时间:2019-06-06

本文共 1141 字,大约阅读时间需要 3 分钟。

1.svd简介

2.svd分解例子

eigen库是一个c++库,实现了线性矩阵部分,其他还有openblas等。如果有时间自己要实现一个SVD的c++代码,现在只用库来代替。eigen不用cmake只要一步配置即可使用。在右键项目,在c/c++常规中附加包含目录包含eigen的解压目录即可。博客 [1]给出了eigen库的配置和使用例程。在官网[2]上给出了一个例子。

完整的代码如下

#include "stdafx.h"#include 
#include
using namespace Eigen; using namespace Eigen::internal; using namespace Eigen::Architecture; using namespace std;int main(){ MatrixXf m = MatrixXf::Random(3,2); cout << "Here is the matrix m:" << endl << m << endl; JacobiSVD
svd(m, ComputeThinU | ComputeThinV); cout << "Its singular values are:" << endl << svd.singularValues() << endl; cout << "Its left singular vectors are the columns of the thin U matrix:" << endl << svd.matrixU() << endl; cout << "Its right singular vectors are the columns of the thin V matrix:" << endl << svd.matrixV() << endl; Vector3f rhs(1, 0, 0); cout << "Now consider this rhs vector:" << endl << rhs << endl; cout << "A least-squares solution of m*x = rhs is:" << endl << svd.solve(rhs) << endl; getchar(); return 0;}

运行的效果如下

3.协同过滤简单例子

4.利用大点的数据集设计推荐系统的例子

[1]

[2]

转载于:https://www.cnblogs.com/hellokittyblog/p/9128470.html

你可能感兴趣的文章
Button MouseEvent颜色变化
查看>>
Volist标签
查看>>
浅谈模块化
查看>>
14个免费访客行为分析工具
查看>>
beego orm关联查询之多对多(m2m)
查看>>
(转)arguments.callee移除AS3匿名函数的侦听
查看>>
onNewIntent调用时机
查看>>
MYSQL GTID使用运维介绍(转)
查看>>
Fail to start neutron-server
查看>>
景安快运挂在磁盘-支持宝塔
查看>>
word中交叉引用不能更新的解决方法
查看>>
高性能HTTP加速器Varnish(概念篇)
查看>>
Linux 如何写makefile文件
查看>>
flutter_webview_plugin 无法加载网页的异常处理
查看>>
bloc控制读写文件
查看>>
微信小程序
查看>>
洛谷 P1059 明明的随机数
查看>>
window自动任务实现数据库定时备份
查看>>
Windows 7 Ultimate(旗舰版)SP1 32/64位官方原版下载(2011年5月12日更新版)
查看>>
javascript操作cookie
查看>>