[{"data":1,"prerenderedAt":1198},["ShallowReactive",2],{"blog-taxonomies":3,"blog-stats":507,"post-2026\u002F2026-01-07-机器学习相关算法":1083},[4,11,16,21,25,29,36,39,44,47,52,58,63,66,71,76,80,84,87,93,96,101,105,110,113,117,122,127,132,136,141,143,146,151,155,157,162,165,169,173,176,179,183,186,190,193,197,200,205,208,211,214,219,222,228,234,237,239,245,249,253,256,260,266,271,276,281,283,287,290,293,298,301,304,306,308,311,314,316,318,321,327,332,337,342,347,352,354,356,358,361,365,367,369,371,374,376,378,381,386,390,393,396,400,404,407,411,413,415,417,421,423,425,428,431,433,435,437,439,441,443,446,448,450,454,456,459,461,463,465,467,469,471,473,477,483,486,488,491,493,495,497,499,501,503,505],{"category":5,"tags":6},"笔记",[7,8,9,10],"QQ","插件","LiteLoader","美化",{"category":12,"tags":13},"其他",[14,15,10],"博客","IP签名",{"category":17,"tags":18},"杂谈",[19,20],"互联网","观点",{"category":5,"tags":22},[14,23,24],"GitHub","数据可视化",{"category":5,"tags":26},[14,27,28],"访问统计","不蒜子",{"category":30,"tags":31},"工具",[32,33,34,35],"Python","爬虫","选课脚本","广州大学",{"category":5,"tags":37},[38,5],"数学分析",{"category":40,"tags":41},"算法",[42,40,43],"数据结构","线性表",{"category":40,"tags":45},[42,46],"复习",{"category":5,"tags":48},[49,50,51],"高等代数","线性代数","知识点",{"category":5,"tags":53},[14,54,55,56,57],"Typora","PicGo","图床","Markdown",{"category":30,"tags":59},[60,61,62],"Jupyter","工具配置","中文",{"category":30,"tags":64},[65,61,10],"VSCode",{"category":30,"tags":67},[68,69,70,35],"路由器","OpenWrt","校园网",{"category":12,"tags":72},[73,74,75],"网络协议","Wireshark","DEVP2P",{"category":5,"tags":77},[73,74,78,79],"Lua","解码器",{"category":5,"tags":81},[82,5,83],"常微分方程","数学",{"category":5,"tags":85},[86,5,83],"概率论",{"category":30,"tags":88},[89,90,91,92],"Docker","WSL","Windows","磁盘清理",{"category":30,"tags":94},[32,33,95,35],"课程表",{"category":5,"tags":97},[14,98,99,100],"Hexo","Gitalk","评论系统",{"category":5,"tags":102},[14,103,98,104],"Obsidian","写作工具",{"category":12,"tags":106},[107,108,109],"课题研究","泊松分布","参数估计",{"category":12,"tags":111},[107,108,109,112],"组会",{"category":12,"tags":114},[109,115,108,116],"IM模型","统计学",{"category":17,"tags":118},[119,120,121],"软考","网络规划","信息系统项目管理",{"category":30,"tags":123},[124,125,126],"Arch Linux","AppImage","Linux",{"category":5,"tags":128},[129,130,131],"编程语言","计算机科学","内存管理",{"category":5,"tags":133},[134,135],"Canvas","前端",{"category":5,"tags":137},[14,138,139,140],"GitHub Actions","Vite","部署",{"category":5,"tags":142},[135],{"category":5,"tags":144},[135,145],"系统设计",{"category":5,"tags":147},[135,148,149,150],"安全","XSS","CSRF",{"category":152,"tags":153},"项目",[134,154],"PixiJS",{"category":152,"tags":156},null,{"category":40,"tags":158},[42,159,160,161],"栈","队列","JavaScript",{"category":40,"tags":163},[42,164,161],"哈希表",{"category":5,"tags":166},[167,161,168],"ES6","Set",{"category":40,"tags":170},[40,171,172],"动态规划","背包问题",{"category":40,"tags":174},[40,175],"滑动窗口",{"category":40,"tags":177},[42,178,161],"链表",{"category":40,"tags":180},[40,181,161,182],"ACM","面试",{"category":40,"tags":184},[40,161,185],"数据类型转换",{"category":40,"tags":187},[42,188,178,189],"顺序表","TypeScript",{"category":5,"tags":191},[135,154,134,192],"渲染",{"category":5,"tags":194},[135,195,134,196],"富文本编辑","wangEditor",{"category":40,"tags":198},[199,40,178],"力扣",{"category":5,"tags":201},[202,203,204,91],"DNS","加密","网络安全",{"category":5,"tags":206},[135,207],"Axios",{"category":5,"tags":209},[135,207,189,210],"接口封装",{"category":5,"tags":212},[135,213,145],"JWT",{"category":152,"tags":215},[134,216,217,154,218],"画布","React","项目开发",{"category":17,"tags":220},[221],"日志",{"category":5,"tags":223},[224,225,226,227],"Neo4j","图数据库","中心度分析","PageRank",{"category":12,"tags":229},[230,231,232,233],"论文","机器学习","随机森林","保险欺诈",{"category":5,"tags":235},[236],"人工智能",{"category":5,"tags":238},[231,40,32],{"category":12,"tags":240},[241,242,243,244],"共识算法","最长链","区块链","算法设计",{"category":5,"tags":246},[161,247,248,135],"闭包","作用域",{"category":5,"tags":250},[14,138,251,252],"RSS","自动化",{"category":30,"tags":254},[89,90,91,255],"安装",{"category":30,"tags":257},[258,91,259],"MSYS2","开发环境",{"category":5,"tags":261},[262,263,264,265],"团队协作","Git","Commit规范","代码审查",{"category":30,"tags":267},[268,269,270],"oh-my-posh","终端美化","CLI",{"category":5,"tags":272},[273,274,275],"上下文工程","Agent","RAG",{"category":5,"tags":277},[278,279,280],"前端工程化","技术选型","工程基建",{"category":5,"tags":282},[275],{"category":5,"tags":284},[285,286],"SDD","规格驱动开发",{"category":5,"tags":288},[289],"neovim",{"category":5,"tags":291},[292],"技术写作",{"category":5,"tags":294},[295,32,296,89,297],"FastAPI","后端","工程实践",{"category":152,"tags":299},[274,300],"Harness Engineering",{"category":5,"tags":302},[303],"RFC",{"category":152,"tags":305},[274,300,275],{"category":152,"tags":307},[274],{"category":40,"tags":309},[199,40,161,310],"两数之和",{"category":40,"tags":312},[199,40,161,313],"双指针",{"category":40,"tags":315},[199,40,161,178],{"category":40,"tags":317},[199,40,161,175],{"category":40,"tags":319},[199,40,161,320],"回溯",{"category":5,"tags":322},[323,324,325,326],"分布式处理与计算","Spark","Scala","RDD",{"category":5,"tags":328},[323,329,330,331],"线性回归","逻辑回归","监督学习",{"category":5,"tags":333},[323,334,335,336],"数值优化","牛顿法","收敛性",{"category":5,"tags":338},[323,339,340,341],"PCA","数据降维","正则化",{"category":5,"tags":343},[323,344,345,346],"聚类","层次聚类","K-Means",{"category":5,"tags":348},[323,349,350,351],"随机模拟","统计推断","EM算法",{"category":5,"tags":353},[24],{"category":5,"tags":355},[24],{"category":5,"tags":357},[24],{"category":40,"tags":359},[42,360],"图论",{"category":40,"tags":362},[42,363,364],"树","二叉树",{"category":40,"tags":366},[42,160],{"category":40,"tags":368},[42],{"category":40,"tags":370},[42,159],{"category":40,"tags":372},[42,40,373],"复杂度分析",{"category":40,"tags":375},[42,43,178],{"category":40,"tags":377},[42,43,188],{"category":40,"tags":379},[42,380],"基础概念",{"category":17,"tags":382},[383,384,385],"随记","照片","高中",{"category":17,"tags":387},[383,388,389],"团建","战地",{"category":17,"tags":391},[383,392],"生活",{"category":17,"tags":394},[383,395],"文学",{"category":17,"tags":397},[383,398,399],"SCP","模因",{"category":17,"tags":401},[383,402,403],"画集","艺术",{"category":17,"tags":405},[14,406,383],"写作",{"category":17,"tags":408},[383,409,410],"音乐","摇滚",{"category":17,"tags":412},[383,392],{"category":17,"tags":414},[383,409],{"category":17,"tags":416},[383,35,392],{"category":17,"tags":418},[383,419,420],"同人","手书",{"category":17,"tags":422},[383,392],{"category":17,"tags":424},[383,392],{"category":17,"tags":426},[383,427],"植物",{"category":17,"tags":429},[383,430],"读书",{"category":17,"tags":432},[383,392],{"category":17,"tags":434},[383,392],{"category":17,"tags":436},[383,392],{"category":17,"tags":438},[383,392],{"category":17,"tags":440},[383,392],{"category":17,"tags":442},[383,392],{"category":17,"tags":444},[14,445,383],"一周年",{"category":17,"tags":447},[383,392],{"category":17,"tags":449},[383,392],{"category":17,"tags":451},[35,452,453],"开源组织","SITE-193",{"category":17,"tags":455},[383,392],{"category":17,"tags":457},[383,458],"年末",{"category":17,"tags":460},[383,392],{"category":17,"tags":462},[383,392],{"category":17,"tags":464},[14,17],{"category":17,"tags":466},[383,392],{"category":17,"tags":468},[383,392],{"category":17,"tags":470},[383,392],{"category":17,"tags":472},[383,392],{"category":17,"tags":474},[383,475,476],"游戏","Control",{"category":30,"tags":478},[479,480,481,482],"Quadim","图像处理","四叉树","Rust",{"category":17,"tags":484},[14,485],"上线纪念",{"category":17,"tags":487},[383,395],{"category":30,"tags":489},[203,490],"测试",{"category":17,"tags":492},[383],{"category":17,"tags":494},[383,392],{"category":17,"tags":496},[383],{"category":5,"tags":498},[40],{"category":5,"tags":500},[40],{"category":5,"tags":502},[40],{"category":5,"tags":504},[40],{"category":5,"tags":506},[40],[508,512,516,520,524,528,532,536,540,544,548,552,556,560,564,568,572,576,579,583,587,590,594,598,602,606,610,614,618,622,626,630,634,638,642,646,650,654,658,662,666,670,674,678,682,686,690,694,698,702,706,710,714,718,722,726,730,734,738,742,746,750,754,758,762,766,770,774,778,782,786,790,794,798,801,805,809,813,817,821,825,829,833,837,841,845,849,853,857,861,865,869,873,877,881,885,889,893,897,901,904,907,911,915,919,923,927,930,934,938,942,946,950,954,957,961,965,969,973,977,981,984,988,992,996,1000,1004,1007,1011,1015,1019,1023,1027,1031,1035,1039,1043,1047,1051,1055,1059,1063,1067,1071,1075,1079],{"path":509,"words":510,"published":511,"date":156},"\u002Fposts\u002F2024\u002F2024-06-25-liteloaderqqnt",1296,"2024-06-25 11:03:08",{"path":513,"words":514,"published":515,"date":156},"\u002Fposts\u002F2024\u002F2024-06-26-ip签名",0,"2024-06-26 22:53:53",{"path":517,"words":518,"published":519,"date":156},"\u002Fposts\u002F2024\u002F2024-06-29-何加盐中文互联网正在加速崩塌",4853,"2024-06-29 00:47:13",{"path":521,"words":522,"published":523,"date":156},"\u002Fposts\u002F2024\u002F2024-07-12-github-chart",270,"2024-07-12 20:02:50",{"path":525,"words":526,"published":527,"date":156},"\u002Fposts\u002F2024\u002F2024-07-14-访客数统计",192,"2024-07-24 01:34:28",{"path":529,"words":530,"published":531,"date":156},"\u002Fposts\u002F2024\u002F2024-07-26-广大选课脚本",110,"2024-07-26 01:34:28",{"path":533,"words":534,"published":535,"date":156},"\u002Fposts\u002F2024\u002F2024-07-26-数学分析笔记其二",14,"2024-07-26 23:54:02",{"path":537,"words":538,"published":539,"date":156},"\u002Fposts\u002F2024\u002F2024-07-26-数据结构复习其二",12856,"2024-07-26 02:48:08",{"path":541,"words":542,"published":543,"date":156},"\u002Fposts\u002F2024\u002F2024-07-26-数据结构复习相关",32856,"2024-07-26 02:24:14",{"path":545,"words":546,"published":547,"date":156},"\u002Fposts\u002F2024\u002F2024-07-26-线性代数与空间解析几何知识点全汇总",6110,"2024-07-26 03:27:55",{"path":549,"words":550,"published":551,"date":156},"\u002Fposts\u002F2024\u002F2024-07-31-typora-picgo-兰空图床打造markdown写作环境",311,"2024-07-31 12:56:23",{"path":553,"words":554,"published":555,"date":156},"\u002Fposts\u002F2024\u002F2024-09-02-jupyter配置中文",441,"2024-09-02 23:49:05",{"path":557,"words":558,"published":559,"date":156},"\u002Fposts\u002F2024\u002F2024-09-02-自定义vscode背景图片",100,"2024-09-02 23:39:00",{"path":561,"words":562,"published":563,"date":156},"\u002Fposts\u002F2024\u002F2024-09-03-制作gzhu校园网路由器",1423,"2024-09-03 23:43:18",{"path":565,"words":566,"published":567,"date":156},"\u002Fposts\u002F2024\u002F2024-09-26-09-25-2024",136,"2024-09-26 00:49:26",{"path":569,"words":570,"published":571,"date":156},"\u002Fposts\u002F2024\u002F2024-11-04-创建一个网络包解码器分析devp2p协议",1943,"2024-11-04 16:45:19",{"path":573,"words":574,"published":575,"date":156},"\u002Fposts\u002F2024\u002F2025-03-09-2024一些笔记常微分",16,"2024-12-09 22:51:00",{"path":577,"words":574,"published":578,"date":156},"\u002Fposts\u002F2024\u002F2025-03-09-2024一些笔记概率论","2025-03-09 22:51:00",{"path":580,"words":581,"published":582,"date":156},"\u002Fposts\u002F2025\u002F2025-03-01-windows下释放docker占用的wsl空间",164,"2025-03-01 13:54:15",{"path":584,"words":585,"published":586,"date":156},"\u002Fposts\u002F2025\u002F2025-03-01-爬虫实战-爬取广州大学课程表",774,"2025-03-01 14:55:48",{"path":588,"words":530,"published":589,"date":156},"\u002Fposts\u002F2025\u002F2025-04-03-hexo集成gitalk的问题","2025-04-03 14:26:34",{"path":591,"words":592,"published":593,"date":156},"\u002Fposts\u002F2025\u002F2025-09-22-记一次配置obsidian配合hexo写博客",92,"2025-09-22 16:47:52",{"path":595,"words":596,"published":597,"date":156},"\u002Fposts\u002F2025\u002F2025-10-24-10-20课题",204,"2025-10-24 08:15:01",{"path":599,"words":600,"published":601,"date":156},"\u002Fposts\u002F2025\u002F2025-11-02-组会朝花夕拾",501,"2025-11-02 18:56:59",{"path":603,"words":604,"published":605,"date":156},"\u002Fposts\u002F2025\u002F2025-11-05-基于随机加权推断模型im的参数估计算法",481,"2025-11-05 20:51:41",{"path":607,"words":608,"published":609,"date":156},"\u002Fposts\u002F2025\u002F2025-11-09-关于软考高项网规",884,"2025-11-09 19:54:52",{"path":611,"words":612,"published":613,"date":156},"\u002Fposts\u002F2025\u002F2025-11-17-arch-linux运行appimage相关",365,"2025-11-17 09:59:59",{"path":615,"words":616,"published":617,"date":156},"\u002Fposts\u002F2025\u002F2025-11-19-相关概念",2058,"2025-11-19 11:06:20",{"path":619,"words":620,"published":621,"date":156},"\u002Fposts\u002F2025\u002F2025-11-21-web可视化实践canvas",6393,"2025-11-21 14:50:48",{"path":623,"words":624,"published":625,"date":156},"\u002Fposts\u002F2025\u002F2025-11-22-使用-github-actions-自动部署基于vite的项目到-github-pages",272,"2025-11-23 01:59:24",{"path":627,"words":628,"published":629,"date":156},"\u002Fposts\u002F2025\u002F2025-11-22-关于前端包管理器npmpnpmyarn和bun",4890,"2025-11-22 21:21:15",{"path":631,"words":632,"published":633,"date":156},"\u002Fposts\u002F2025\u002F2025-11-23-undo-redo-机制具体实现",7839,"2025-11-23 19:15:00",{"path":635,"words":636,"published":637,"date":156},"\u002Fposts\u002F2025\u002F2025-11-27-前端安全-关于xss与crsf",1866,"2025-11-28 02:05:25",{"path":639,"words":640,"published":641,"date":156},"\u002Fposts\u002F2025\u002F2025-12-05-现代协同-2d-画布编辑器pixijs-v8",4285,"2025-12-05 02:00:16",{"path":643,"words":644,"published":645,"date":156},"\u002Fposts\u002F2025\u002F2025-12-07-杂谈-课题组系统设计",3710,"2025-12-07 21:09:33",{"path":647,"words":648,"published":649,"date":156},"\u002Fposts\u002F2025\u002F2025-12-25-javascript中的数组方法与栈stack和队列queue的实现",474,"2025-11-29 16:58:15",{"path":651,"words":652,"published":653,"date":156},"\u002Fposts\u002F2025\u002F2025-12-25-关于javascript-实现哈希表",189,"2025-11-27 11:31:39",{"path":655,"words":656,"published":657,"date":156},"\u002Fposts\u002F2025\u002F2025-12-25-关于javascript的set方法",332,"2025-12-25 15:26:18",{"path":659,"words":660,"published":661,"date":156},"\u002Fposts\u002F2025\u002F2025-12-25-关于动态规划(背包问题为例)",1238,"2025-11-17 18:24:04",{"path":663,"words":664,"published":665,"date":156},"\u002Fposts\u002F2025\u002F2025-12-25-关于滑动窗口",712,"2025-11-20 15:04:40",{"path":667,"words":668,"published":669,"date":156},"\u002Fposts\u002F2025\u002F2025-12-25-关于链表(javascript)",500,"2025-11-25 13:00:48",{"path":671,"words":672,"published":673,"date":156},"\u002Fposts\u002F2025\u002F2025-12-25-面试算法acm模式构建构建输入输出模板",2051,"2025-12-25 23:09:45",{"path":675,"words":676,"published":677,"date":156},"\u002Fposts\u002F2025\u002F2025-12-26-javascript-数字数组字符串的处理",483,"2025-12-26 11:20:25",{"path":679,"words":680,"published":681,"date":156},"\u002Fposts\u002F2025\u002F2025-12-26-javascripttypescript-的顺序表链表实现",446,"2025-12-26 12:16:12",{"path":683,"words":684,"published":685,"date":156},"\u002Fposts\u002F2025\u002F2025-12-27-前端画布设计vol-1-实现基础yuan素渲染和状态控制",2136,"2025-12-28 01:23:08",{"path":687,"words":688,"published":689,"date":156},"\u002Fposts\u002F2025\u002F2025-12-27-前端画布设计vol-2-实现富文本编辑",1838,"2025-12-28 02:58:47",{"path":691,"words":692,"published":693,"date":156},"\u002Fposts\u002F2025\u002F2025-12-27-算法刷题-关于链表操作",2135,"2025-12-27 16:12:42",{"path":695,"words":696,"published":697,"date":156},"\u002Fposts\u002F2025\u002F2025-12-27-配置dnscrypt-proxy实现加密dns服务windows",1899,"2025-11-15 01:06:37",{"path":699,"words":700,"published":701,"date":156},"\u002Fposts\u002F2025\u002F2025-12-28-前端-关于网络请求xhrajaxfetchaxios",7788,"2025-10-28 15:48:46",{"path":703,"words":704,"published":705,"date":156},"\u002Fposts\u002F2025\u002F2025-12-28-前端-接口封装与请求规范axios为例",2373,"2025-12-29 01:01:18",{"path":707,"words":708,"published":709,"date":156},"\u002Fposts\u002F2025\u002F2025-12-28-前端-身份验证管理-基于-jwt-token-的实现",2709,"2025-11-23 22:04:41",{"path":711,"words":712,"published":713,"date":156},"\u002Fposts\u002F2025\u002F2025-12-29-记canvas画布项目开发",6254,"2025-12-29 04:52:15",{"path":715,"words":716,"published":717,"date":156},"\u002Fposts\u002F2025\u002Fabout-site",116,"2025-03-31 16:44:24",{"path":719,"words":720,"published":721,"date":156},"\u002Fposts\u002F2025\u002F使用neo4j图数据科学库gds进行中心度分析",143,"2025-04-02 23:37:24",{"path":723,"words":724,"published":725,"date":156},"\u002Fposts\u002F2026\u002F2026-01-03-论文实训草稿",10445,"2026-01-03 14:10:49",{"path":727,"words":728,"published":729,"date":156},"\u002Fposts\u002F2026\u002F2026-01-06-人工智能导论",11461,"2026-01-07 03:25:49",{"path":731,"words":732,"published":733,"date":156},"\u002Fposts\u002F2026\u002F2026-01-07-机器学习相关算法",82,"2026-01-08 02:28:13",{"path":735,"words":736,"published":737,"date":156},"\u002Fposts\u002F2026\u002F2026-01-16-关于低复杂度最长链共识算法设计",4466,"2026-01-16 10:33:23",{"path":739,"words":740,"published":741,"date":156},"\u002Fposts\u002F2026\u002F2026-01-19-杂记2026-01-19",5754,"2026-01-20 01:03:26",{"path":743,"words":744,"published":745,"date":156},"\u002Fposts\u002F2026\u002F2026-01-22-github-action-自动同步博客到-github-主页",1069,"2026-01-22 16:31:47",{"path":747,"words":748,"published":749,"date":156},"\u002Fposts\u002F2026\u002F2026-03-01-windows-wsl安装docker",257,"2026-03-01 20:55:31",{"path":751,"words":752,"published":753,"date":156},"\u002Fposts\u002F2026\u002F2026-03-14-关于-msys2",701,"2026-03-15 03:05:04",{"path":755,"words":756,"published":757,"date":156},"\u002Fposts\u002F2026\u002F2026-03-28-团队项目协作规范随记",2419,"2026-03-29 05:33:50",{"path":759,"words":760,"published":761,"date":156},"\u002Fposts\u002F2026\u002F2026-03-29-oh-my-posh配置分享",104,"2026-03-29 16:34:43",{"path":763,"words":764,"published":765,"date":156},"\u002Fposts\u002F2026\u002F2026-06-13-从上下文工程到-agent-harness-engineering",8840,"2026-06-13 21:06:20",{"path":767,"words":768,"published":769,"date":156},"\u002Fposts\u002F2026\u002F2026-07-13-简谈前端基建质量标准与ai友好建设",3814,"2026-07-13 21:06:20",{"path":771,"words":772,"published":773,"date":156},"\u002Fposts\u002F2026\u002F2026-07-15-agentic-rag-系统实践",13357,"2026-07-15 21:06:20",{"path":775,"words":776,"published":777,"date":156},"\u002Fposts\u002F2026\u002F2026-07-18-简谈sdd规范驱动开发-copy",4476,"2026-07-18 11:06:20",{"path":779,"words":780,"published":781,"date":156},"\u002Fposts\u002F2026\u002F2026-07-20-个人neovim配置分享",366,"2026-07-22 13:46:50",{"path":783,"words":784,"published":785,"date":156},"\u002Fposts\u002F2026\u002F2026-07-20-关于技术写作-设计文档",6763,"2026-07-20 13:46:50",{"path":787,"words":788,"published":789,"date":156},"\u002Fposts\u002F2026\u002F2026-07-29-fastapi-工程实践随记",3417,"2026-07-29 04:58:34",{"path":791,"words":792,"published":793,"date":156},"\u002Fposts\u002Frfc_agentic_project\u002F2026-06-19-rfc-liskin_code_agent",3563,"2026-06-19 15:18:20",{"path":795,"words":796,"published":797,"date":156},"\u002Fposts\u002Frfc_agentic_project\u002F2026-07-25-rfc-glushkov_ogas",13461,"2026-07-28 23:46:50",{"path":799,"words":800,"published":793,"date":156},"\u002Fposts\u002Frfc_agentic_project\u002F2026-08-03-adr-ogas-arkhiv",2698,{"path":802,"words":803,"published":804,"date":156},"\u002Fposts\u002Frfc_agentic_project\u002Frag\u002F2026-08-12-arkhiv_rag-vol-1",4366,"2026-08-12 15:18:20",{"path":806,"words":807,"published":808,"date":156},"\u002Fposts\u002Fleetcode\u002F2025-12-25-力扣百题速练javascripttypescriptvol-1",3108,"2025-12-25 13:57:08",{"path":810,"words":811,"published":812,"date":156},"\u002Fposts\u002Fleetcode\u002F2025-12-26-力扣百题速练javascripttypescriptvol-2",3185,"2025-12-26 13:57:08",{"path":814,"words":815,"published":816,"date":156},"\u002Fposts\u002Fleetcode\u002F2025-12-28-力扣百题速练javascripttypescriptvol-3",2533,"2025-12-29 02:15:44",{"path":818,"words":819,"published":820,"date":156},"\u002Fposts\u002Fleetcode\u002F2026-01-17-力扣百题速练javascripttypescriptvol-4",3024,"2026-01-17 22:53:01",{"path":822,"words":823,"published":824,"date":156},"\u002Fposts\u002Fleetcode\u002F2026-01-19-力扣百题速练javascripttypescriptvol-5",293,"2026-01-19 15:15:12",{"path":826,"words":827,"published":828,"date":156},"\u002Fposts\u002F分布式处理与计算\u002F分布式处理与计算spark系统与scala语言",4320,"2026-07-06 14:10:49",{"path":830,"words":831,"published":832,"date":156},"\u002Fposts\u002F分布式处理与计算\u002F分布式处理与计算分类与回归分析",2081,"2026-07-07 12:40:29",{"path":834,"words":835,"published":836,"date":156},"\u002Fposts\u002F分布式处理与计算\u002F分布式处理与计算数值优化方法",2182,"2026-07-07 13:50:29",{"path":838,"words":839,"published":840,"date":156},"\u002Fposts\u002F分布式处理与计算\u002F分布式处理与计算数据降维",1583,"2026-07-07 21:50:29",{"path":842,"words":843,"published":844,"date":156},"\u002Fposts\u002F分布式处理与计算\u002F分布式处理与计算聚类分析",1882,"2026-07-07 16:50:29",{"path":846,"words":847,"published":848,"date":156},"\u002Fposts\u002F分布式处理与计算\u002F分布式处理与计算随机模拟与统计推断",2433,"2026-07-06 22:40:29",{"path":850,"words":851,"published":852,"date":156},"\u002Fposts\u002F数据可视化\u002F2026-06-14-数据可视化-基本图像",10011,"2026-06-14 20:18:20",{"path":854,"words":855,"published":856,"date":156},"\u002Fposts\u002F数据可视化\u002F2026-06-14-数据可视化-概论",10030,"2026-06-14 15:18:20",{"path":858,"words":859,"published":860,"date":156},"\u002Fposts\u002F数据可视化\u002F2026-06-15-数据可视化-可视化库",2032,"2026-06-15 20:18:20",{"path":862,"words":863,"published":864,"date":156},"\u002Fposts\u002F数据结构\u002F2025-09-29-数据结构-图",5451,"2025-04-15 20:48:06",{"path":866,"words":867,"published":868,"date":156},"\u002Fposts\u002F数据结构\u002F2025-09-29-数据结构-树",4211,"2025-04-30 02:19:06",{"path":870,"words":871,"published":872,"date":156},"\u002Fposts\u002F数据结构\u002F2025-09-29-数据结构-队列",921,"2025-04-11 15:30:08",{"path":874,"words":875,"published":876,"date":156},"\u002Fposts\u002F数据结构\u002F关于数据结构的一些想法",456,"2025-04-04 19:13:49",{"path":878,"words":879,"published":880,"date":156},"\u002Fposts\u002F数据结构\u002F数据结构-栈",920,"2025-04-18 00:17:37",{"path":882,"words":883,"published":884,"date":156},"\u002Fposts\u002F数据结构\u002F数据结构-算法复杂度",2153,"2025-04-05 16:09:55",{"path":886,"words":887,"published":888,"date":156},"\u002Fposts\u002F数据结构\u002F数据结构-线性表链表",4572,"2025-04-06 00:24:40",{"path":890,"words":891,"published":892,"date":156},"\u002Fposts\u002F数据结构\u002F数据结构-线性表顺序表",4191,"2025-04-05 22:09:59",{"path":894,"words":895,"published":896,"date":156},"\u002Fposts\u002F数据结构\u002F数据结构-绪论",2881,"2025-04-05 11:31:22",{"path":898,"words":899,"published":156,"date":900},"\u002Fposts\u002F杂记\u002F2023-12-26-2023年12月26日",7,"2023-12-26 23:51:33",{"path":902,"words":899,"published":156,"date":903},"\u002Fposts\u002F杂记\u002F2024-01-01-2024团建","2024-01-01 01:51:27",{"path":905,"words":581,"published":156,"date":906},"\u002Fposts\u002F杂记\u002F2024-01-09-随记","2024-01-09 20:50:35",{"path":908,"words":909,"published":156,"date":910},"\u002Fposts\u002F杂记\u002F2024-03-12-花名",5275,"2024-03-12 16:04:23",{"path":912,"words":913,"published":156,"date":914},"\u002Fposts\u002F杂记\u002F2024-04-15-逆模因",1353,"2024-04-15 00:26:16",{"path":916,"words":917,"published":156,"date":918},"\u002Fposts\u002F杂记\u002F2024-05-03-艺作",27,"2024-05-03 00:01:00",{"path":920,"words":921,"published":156,"date":922},"\u002Fposts\u002F杂记\u002F2024-05-21-关于博客",1720,"2024-02-21 23:21:11",{"path":924,"words":925,"published":156,"date":926},"\u002Fposts\u002F杂记\u002F2024-06-20-dnvrc维克多崔专访-2023",2036,"2024-06-20 00:28:39",{"path":928,"words":760,"published":156,"date":929},"\u002Fposts\u002F杂记\u002F2024-06-25-6月25日随记","2024-06-25 12:46:36",{"path":931,"words":932,"published":156,"date":933},"\u002Fposts\u002F杂记\u002F2024-06-25-歌名-想見星星",148,"2024-06-25 22:47:59",{"path":935,"words":936,"published":156,"date":937},"\u002Fposts\u002F杂记\u002F2024-07-11-桂花岗",6,"2024-07-11 00:28:17",{"path":939,"words":940,"published":156,"date":941},"\u002Fposts\u002F杂记\u002F2024-07-15-rolling-bocci",9,"2024-07-15 21:25:56",{"path":943,"words":944,"published":156,"date":945},"\u002Fposts\u002F杂记\u002F2024-07-22-七月九日",34,"2024-07-09 17:54:23",{"path":947,"words":948,"published":156,"date":949},"\u002Fposts\u002F杂记\u002F2024-07-22-六月随记",1052,"2024-07-22 01:03:19",{"path":951,"words":952,"published":156,"date":953},"\u002Fposts\u002F杂记\u002F2024-07-22-石菖蒲",41,"2024-07-10 01:26:05",{"path":955,"words":514,"published":156,"date":956},"\u002Fposts\u002F杂记\u002F2024-07-23-新书","2024-07-23 01:05:49",{"path":958,"words":959,"published":156,"date":960},"\u002Fposts\u002F杂记\u002F2024-07-29-年前",74,"2024-07-29 23:59:07",{"path":962,"words":963,"published":156,"date":964},"\u002Fposts\u002F杂记\u002F2024-07-30-周边",138,"2024-07-30 02:03:23",{"path":966,"words":967,"published":156,"date":968},"\u002Fposts\u002F杂记\u002F2024-07-31-2024-7-31日",185,"2024-07-31 01:21:52",{"path":970,"words":971,"published":156,"date":972},"\u002Fposts\u002F杂记\u002F2024-08-02-八月",1710,"2024-08-30 00:31:02",{"path":974,"words":975,"published":156,"date":976},"\u002Fposts\u002F杂记\u002F2024-09-01-九月",1484,"2024-09-26 16:30:15",{"path":978,"words":979,"published":156,"date":980},"\u002Fposts\u002F杂记\u002F2024-09-08-2024年9月8日",97,"2024-09-08 13:59:36",{"path":982,"words":514,"published":156,"date":983},"\u002Fposts\u002F杂记\u002F2024-09-19-博客站的一周年","2024-09-18 23:36:24",{"path":985,"words":986,"published":156,"date":987},"\u002Fposts\u002F杂记\u002F2024-10-03-十月",1028,"2024-10-31 23:54:27",{"path":989,"words":990,"published":156,"date":991},"\u002Fposts\u002F杂记\u002F2024-11-04-十一月",2134,"2024-11-30 00:04:39",{"path":993,"words":994,"published":156,"date":995},"\u002Fposts\u002F杂记\u002F2024-11-10-gzhu-site-193",80,"2024-11-10 19:19:12",{"path":997,"words":998,"published":156,"date":999},"\u002Fposts\u002F杂记\u002F2024-12-01-十二月",455,"2024-12-30 23:13:47",{"path":1001,"words":1002,"published":156,"date":1003},"\u002Fposts\u002F杂记\u002F2024-12-21-年末",23,"2024-12-21 23:21:49",{"path":1005,"words":522,"published":156,"date":1006},"\u002Fposts\u002F杂记\u002F2025-01-30-一月","2025-01-30 23:44:41",{"path":1008,"words":1009,"published":156,"date":1010},"\u002Fposts\u002F杂记\u002F2025-03-01-二月",224,"2025-02-28 00:11:08",{"path":1012,"words":1013,"published":156,"date":1014},"\u002Fposts\u002F杂记\u002F2025-03-01-博客杂谈",344,"2025-03-01 16:03:18",{"path":1016,"words":1017,"published":156,"date":1018},"\u002Fposts\u002F杂记\u002F2025-03-05-三月",2090,"2025-03-05 19:17:28",{"path":1020,"words":1021,"published":156,"date":1022},"\u002Fposts\u002F杂记\u002F2025-07-10-七月",361,"2025-07-10 22:04:32",{"path":1024,"words":1025,"published":156,"date":1026},"\u002Fposts\u002F杂记\u002F2025-09-21-九月",781,"2025-09-21 20:53:37",{"path":1028,"words":1029,"published":156,"date":1030},"\u002Fposts\u002F杂记\u002F2025-10-09-十月",591,"2025-10-09 00:35:07",{"path":1032,"words":1033,"published":156,"date":1034},"\u002Fposts\u002F杂记\u002Fcontrol",13,"2023-09-25 13:03:59",{"path":1036,"words":1037,"published":156,"date":1038},"\u002Fposts\u002F杂记\u002Fquadim四叉树图像处理",1094,"2023-10-21 11:27:06",{"path":1040,"words":1041,"published":156,"date":1042},"\u002Fposts\u002F杂记\u002Fsuccess",24,"2023-09-22 15:59:07",{"path":1044,"words":1045,"published":156,"date":1046},"\u002Fposts\u002F杂记\u002F三光年",295,"2023-11-18 04:18:40",{"path":1048,"words":1049,"published":156,"date":1050},"\u002Fposts\u002F杂记\u002F加密测试",961,"2023-11-21 14:24:01",{"path":1052,"words":1053,"published":156,"date":1054},"\u002Fposts\u002F杂记\u002F啊啊啊啊啊啊啊",54,"2023-09-20 17:29:33",{"path":1056,"words":1057,"published":156,"date":1058},"\u002Fposts\u002F杂记\u002F杂谈",124,"2023-09-25 23:11:32",{"path":1060,"words":1061,"published":156,"date":1062},"\u002Fposts\u002F杂记\u002F艹",25,"2023-10-21 17:40:43",{"path":1064,"words":1065,"published":1066,"date":156},"\u002Fposts\u002F神经网络\u002F神经网络与深度学习卷积神经网络",3168,"2026-06-07 11:23:08",{"path":1068,"words":1069,"published":1070,"date":156},"\u002Fposts\u002F神经网络\u002F神经网络与深度学习循环神经网络",2348,"2026-06-07 11:33:08",{"path":1072,"words":1073,"published":1074,"date":156},"\u002Fposts\u002F神经网络\u002F神经网络与深度学习改进学习方法",3360,"2026-06-07 10:13:08",{"path":1076,"words":1077,"published":1078,"date":156},"\u002Fposts\u002F神经网络\u002F神经网络与深度学习深度生成模型",2727,"2026-06-07 11:43:08",{"path":1080,"words":1081,"published":1082,"date":156},"\u002Fposts\u002F神经网络\u002F神经网络与深度学习神经网络基础",3205,"2026-06-07 10:03:08",{"id":1084,"title":1085,"abbrlink":1086,"body":1087,"category":5,"cover":156,"date":156,"description":1102,"extension":1188,"mathjax":1189,"meta":1190,"navigation":1189,"path":731,"published":733,"readingMinutes":1193,"seo":1194,"stem":1195,"sticky":156,"swiper_index":156,"tags":1196,"updated":156,"words":732,"__hash__":1197},"posts\u002Fposts\u002F2026\u002F2026-01-07-机器学习相关算法.md","2026-01-07-机器学习相关笔记","11390",{"type":1088,"value":1089,"toc":1174},"minimark",[1090,1095,1106,1111,1117,1121,1127,1131,1137,1140,1146,1149,1155,1158,1164,1168],[1091,1092,1094],"h2",{"id":1093},"评估方法留出法","评估方法（留出法）",[1096,1097,1103],"pre",{"className":1098,"code":1100,"language":1101,"meta":1102},[1099],"language-python","import random\nimport numpy as np\n\ndef train_test_split(X,test_size=0.2,random_state=5):\n    random.seed(random_state)\n    n_samples = len(X)\n    indices = np.arange(n_samples)\n    train_indexs = list(set(random.sample(indices.tolist(),int(n_samples*(1-test_size)))))\n    test_indexs = [k for k in indices if k not in train_indexs]\n    return X[train_indexs],X[test_indexs]\n\n\ntest_size = 0.2\nX = np.array([1,2,3,4,5,6,7,8,9,10])\ntrain_X,test_X = train_test_split(X,test_size=test_size)\nprint(train_X,test_X)\n\nprint(\"debug_begin\");\nprint(len(test_X) == int(len(X)*test_size))\nprint(\"debug_end\");\n","python","",[1104,1105,1100],"code",{"__ignoreMap":1102},[1107,1108,1110],"h3",{"id":1109},"评估方法交叉验证法","评估方法（交叉验证法）",[1096,1112,1115],{"className":1113,"code":1114,"language":1101,"meta":1102},[1099],"import numpy as np\nimport random\n\ndef KFold(X,n_splits,is_shuffle=True,random_state=0):\n    random.seed(random_state)\n    n_samples = len(X)\n\n    indices = np.arange(n_samples)\n\n    train_index = []\n    test_index = []\n    result = []\n    fold_sizes = np.full(n_splits,n_samples\u002F\u002Fn_splits,dtype=np.int)\n    fold_sizes[:n_samples%n_splits] += 1\n    current = 0\n    for fold_size in fold_sizes:\n        start, stop = current, current+fold_size\n        test_index = indices[start:stop]\n        train_index = list(set(indices)-set(indices[start:stop]))\n        current = stop\n        result.append([X[train_index],X[test_index]])\n    return result\n\nX = np.array([int(i) for i in input().strip().split()])\nn_splits = int(input())\nresult = KFold(X,n_splits)\n\n\nfor S,T in result:\n    print(S,T)\n\n\nprint(\"debug_begin\");\nres = []\nfor _,T in result:\n    res += list(T)\nif set(res)==set(list(X)) and len(X)==len(res):\n    print(True)\nelse:\n    print(False)\nprint(\"debug_end\");\n",[1104,1116,1114],{"__ignoreMap":1102},[1107,1118,1120],{"id":1119},"优化算法-梯度下降法-1","优化算法-梯度下降法 1",[1096,1122,1125],{"className":1123,"code":1124,"language":1101,"meta":1102},[1099],"import math\nprint(\"debug_begin\");\ndef func_1d_test1(x):\n    return x**2+1\ndef grad_1d_test1(x):\n    return x*2\n\ndef func_1d_test2(x):\n    return x**2 - 4*x +14\ndef grad_1d_test2(x):\n    return x*2-4\nprint(\"debug_end\");\n\n\ndef gradient_descent_1d(grad, cur_x=0.1, learning_rate=0.01, precision=0.0001, max_iters=10000):\n    for i in range(max_iters):\n        grad_cur = grad(cur_x)\n        if abs(grad_cur) \u003C precision:\n            break  # 当梯度趋近为 0 时，视为收敛\n        cur_x = cur_x - grad_cur * learning_rate\n\n    return cur_x\n\nprint(\"debug_begin\");\ndef test():\n    print(\"%.7f\" %gradient_descent_1d(grad_1d_test1, cur_x=10, learning_rate=0.2, precision=0.0001, max_iters=10000))\n    print(\"%.7f\" %gradient_descent_1d(grad_1d_test2, cur_x=10, learning_rate=0.2, precision=0.0001, max_iters=10000))\nprint(\"debug_end\");\n\ntest()\n",[1104,1126,1124],{"__ignoreMap":1102},[1091,1128,1130],{"id":1129},"优化算法-梯度下降法-2","优化算法-梯度下降法 2",[1096,1132,1135],{"className":1133,"code":1134,"language":1101,"meta":1102},[1099],"import math\nimport numpy as np\n\nprint(\"debug_begin\");\nimport numpy as np\ndef func_2d_test1(x):\n    return - math.exp(-(x[0] ** 2 + x[1] ** 2))\ndef grad_2d_test1(x):\n    deriv0 = 2 * x[0] * math.exp(-(x[0] ** 2 + x[1] ** 2))\n    deriv1 = 2 * x[1] * math.exp(-(x[0] ** 2 + x[1] ** 2))\n    return np.array([deriv0, deriv1])\n\ndef func_2d_test2(x):\n    return x[0]**2 + x[1]**2 +2*x[0]+1\ndef grad_2d_test2(x):\n    deriv0 = 2*x[0]+2\n    deriv1 = 2*x[1]\n    return np.array([deriv0,deriv1])\nprint(\"debug_end\");\n\n\ndef gradient_descent_2d(grad, cur_x=np.array([0.1,0.1]), learning_rate=0.01, precision=0.0001, max_iters=10000):\n    for i in range(max_iters):\n        grad_cur = grad(cur_x)\n        if np.linalg.norm(grad_cur, ord=2) \u003C precision:\n            break  # 当梯度趋近为 0 时，视为收敛\n        cur_x = cur_x - grad_cur * learning_rate\n\n\n    return cur_x\n\n\nprint(\"debug_begin\");\nimport numpy as np\ndef test():\n    res = gradient_descent_2d(grad_2d_test1, cur_x=np.array([1,-1]), learning_rate=0.2, precision=0.0001, max_iters=10000)\n    print(\"%.7f %.7f\" %(res[0],res[1]) )\n    res2 = gradient_descent_2d(grad_2d_test2, cur_x=np.array([2,2]), learning_rate=0.2, precision=0.0001, max_iters=10000)\n    print(\"%.7f %.7f\" %(res2[0],res2[1]) )\nprint(\"debug_end\");\n\ntest()\n",[1104,1136,1134],{"__ignoreMap":1102},[1091,1138,1139],{"id":1139},"线性回归-糖尿病预测",[1096,1141,1144],{"className":1142,"code":1143,"language":1101,"meta":1102},[1099],"import math\nimport numpy as np\nimport random\nimport  warnings\nwarnings.filterwarnings(\"ignore\")\n\ndef load_diabetes():\n    X = []\n    y = []\n    line = input()\n    while line:\n        dx = []\n        data = [l for l in line.strip().split(',')]\n        X.append(np.array([np.float(d) for d in data[:-1]]))\n        y.append(np.float(data[-1]))\n        line = input()\n    return np.array(X),np.array(y)\n\ndef train_test_split(X,Y,test_size=0.2,random_state=2333):\n    random.seed(random_state)\n    n_samples = len(X)\n    indices = np.arange(n_samples)\n    train_indexs = list(set(random.sample(indices.tolist(),int(n_samples*(1-test_size)))))\n    test_indexs = [k for k in indices if k not in train_indexs]\n    return X[train_indexs],X[test_indexs],Y[train_indexs],Y[test_indexs]\n\nX,y = load_diabetes()\nimport math\nimport numpy as np\nimport random\nimport  warnings\nwarnings.filterwarnings(\"ignore\")\n\ndef load_diabetes():\n    X = []\n    y = []\n    line = input()\n    while line:\n        dx = []\n        data = [l for l in line.strip().split(',')]\n        X.append(np.array([np.float(d) for d in data[:-1]]))\n        y.append(np.float(data[-1]))\n        line = input()\n    return np.array(X),np.array(y)\n\ndef train_test_split(X,Y,test_size=0.2,random_state=2333):\n    random.seed(random_state)\n    n_samples = len(X)\n    indices = np.arange(n_samples)\n    train_indexs = list(set(random.sample(indices.tolist(),int(n_samples*(1-test_size)))))\n    test_indexs = [k for k in indices if k not in train_indexs]\n    return X[train_indexs],X[test_indexs],Y[train_indexs],Y[test_indexs]\n\nX,y = load_diabetes()\nclass LinearRegression:\n  def __init__(self):\n    '''初始化模型'''\n    self.coef_ = None\n    self.interception_ = None\n    self._theta = None\n\n  def fit_normal(self,X_train,y_train):\n    '''根据训练数据集X_train,y_train训练模型'''\n    assert X_train.shape[0] == y_train.shape[0],'the number of X_train must equal to the number of y_train'\n    X_b = np.hstack([np.ones((len(X_train),1)),X_train])\n    self._theta = np.linalg.inv(X_b.T.dot(X_b)).dot(X_b.T).dot(y_train)\n    self.interception_ = self._theta[0]\n    self.coef_ = self._theta[1:]\n    return self\n\n  def predict(self,X_predict):\n    assert self._theta is not None,'must fit before predict'\n    assert X_predict.shape[1] == len(self.coef_),'the feature number of X_predict must equal to X_train '\n\n    X_b = np.hstack([np.ones((len(X_predict),1)),X_predict])\n    return X_b.dot(self._theta)\n\n  def mse(self,y,y_pre):\n    return np.average((y-y_pre)**2)\n\n  def rmse(self,y,y_pre):\n    return np.sqrt(self.mse(y,y_pre))\n\n  def r2_score(self,y,y_pre):\n    return 1-(self.mse(y,y_pre)\u002Fnp.var(y))\n\n  def score(self,X_test,y_test):\n    '''根据测试数据集确定当前模型的准确度'''\n    y_predict = self.predict(X_test)\n    return self.r2_score(y_test,y_predict),self.rmse(y_test,y_predict)\n\n  def __repr__(self):\n    return 'LinearRegression()'\n\nx_train,x_test,y_train,y_test = train_test_split(X,y)\n\nreg = LinearRegression()\nreg.fit_normal(x_train,y_train)\nr2,rmse = reg.score(x_test,y_test)\n\n\nprint(\"debug_begin\");\ndef test(rmse,r2):\n    if rmse>50 or r2>0.5:\n        print(True)\n    else:\n        print(False)\n\nprint(\"debug_end\");\ntest(rmse,r2)\n\n\nprint(\"debug_begin\");\ndef test(rmse,r2):\n    if rmse>50 or r2>0.5:\n        print(True)\n    else:\n        print(False)\n\nprint(\"debug_end\");\ntest(rmse,r2)\n\n",[1104,1145,1143],{"__ignoreMap":1102},[1091,1147,1148],{"id":1148},"逻辑回归-乳腺癌预测",[1096,1150,1153],{"className":1151,"code":1152,"language":1101,"meta":1102},[1099],"import numpy as np\nimport random\nimport warnings\nwarnings.filterwarnings(\"ignore\")\n\ndef load_breast_cancer():\n    X = []\n    y = []\n    line = input()\n    while line:\n        dx = []\n        data = [np.float64(l) for l in line.strip().split(',')]\n        X.append(np.array(data[:-1]))\n        y.append(int(data[-1]))\n        line = input()\n    return np.array(X),np.array(y)\n\ndef train_test_split(X,Y,test_size=0.2,random_state=5):\n    n_samples = len(X)\n    indices = np.arange(n_samples)\n    train_indexs = list(set(random.sample(indices.tolist(),int(n_samples*(1-test_size)))))\n    test_indexs = [k for k in indices if k not in train_indexs]\n    return X[train_indexs],X[test_indexs],Y[train_indexs],Y[test_indexs]\n\nX,y = load_breast_cancer()\nx_train,x_test,y_train,y_test = train_test_split(X,y)\nclass Logisticregression():\n\n\n    def __init__(self, learn_rate = 0.001, max_iteration=10000):\n\n        self.learn_rate = learn_rate\n        self.max_iteration = max_iteration\n        self._X_train = None\n        self._y_train = None\n        self._w = None\n\n    def fit(self, X_train, y_train):\n\n        m_samples, n_features = X_train.shape\n        self._X_train = np.insert(X_train, 0, 1, axis=1)\n        self._y_train = np.reshape(y_train, (m_samples, 1))\n        limit = np.sqrt(1 \u002F n_features)\n        w = np.random.uniform(-limit, limit, (n_features, 1))\n        b = 0\n        self.w = np.insert(w, 0, b, axis=0)\n        iteration = 0\n        while iteration \u003C self.max_iteration:\n            h_x = self._X_train.dot(self.w)\n            y_pred = 1\u002F(1+np.exp(- h_x))\n            w_grad = self._X_train.T.dot(y_pred - self._y_train)\n            self.w = self.w - self.learn_rate * w_grad\n            iteration = iteration + 1\n\n    def predict(self, X_test):\n\n        X_test = np.insert(X_test, 0, 1, axis=1)\n        h_x = X_test.dot(self.w)\n        y_pripr_1 = (1\u002F(1+np.exp(-h_x)))\n        y_pripr_0 = 1 - y_pripr_1\n        y_cal = y_pripr_1 - y_pripr_0\n        y_class = np.where(y_cal > 0, 1, 0)\n        return y_class\n\n    def score(self, X_test, y_test):\n\n        j = 0\n        y_test = np.reshape(y_test,(len(y_test),1))\n        y_hat = self.predict(X_test)\n        for i in range(y_test.shape[0]):\n            if y_hat[i,0] == y_test[i,0]:\n                j += 1\n        acc = j \u002F len(y_test)\n        y_test = list(y_test.reshape((1,-1))[0])\n        y_hat = list(y_hat.reshape((1,-1))[0])\n\n        precision = self.get_precision(y_test,y_hat)\n        recall = self.get_recall(y_test,y_hat)\n        auc = self.get_auc(y_test,y_hat)\n        return acc,precision,recall,auc\n\n\n    def get_precision(self,y,y_hat):\n        true_positive = sum(yi and yi_hat for yi,yi_hat in zip(y,y_hat))\n        predicted_positive = sum(y_hat)\n        return true_positive\u002Fpredicted_positive\n\n    def get_recall(self,y,y_hat):\n        true_positive = sum(yi and yi_hat for yi,yi_hat in zip(y,y_hat))\n        actual_positive = sum(y)\n        return true_positive\u002Factual_positive\n\n\n    def get_tnr(self,y,y_hat):\n        true_negative = sum(1-(yi or yi_hat) for yi,yi_hat in zip(y,y_hat))\n        actual_negative = len(y) - sum(y)\n        return true_negative\u002Factual_negative\n\n    def get_roc(self,y,y_hat):\n        thresholds = sorted(set(y_hat),reverse=True)\n        ret = [[0,0]]\n        for threshold in thresholds:\n            y_hat = [int(yi_hat >= threshold) for yi_hat in y_hat]\n            ret.append([self.get_recall(y,y_hat),1-self.get_tnr(y,y_hat)])\n        return ret\n\n    def get_auc(self,y,y_hat):\n        roc = iter(self.get_roc(y,y_hat))\n        tpr_pre, fpr_pre = next(roc)\n        auc = 0\n        for tpr,fpr in roc:\n            auc += (tpr+tpr_pre)*(fpr-fpr_pre)\u002F2\n            tpr_pre = tpr\n            fpr_pre = fpr\n        return auc\n\nlr = Logisticregression()\nlr.fit(x_train,y_train)\nacc,precision,recall,auc = lr.score(x_test,y_test)\n\n\nprint(\"debug_begin\");\ndef test(acc,auc):\n    if acc>0.8 or auc>0.8:\n        print(True)\n    else:\n        print(False)\nprint(\"debug_end\");\ntest(acc,auc)\n\n",[1104,1154,1152],{"__ignoreMap":1102},[1091,1156,1157],{"id":1157},"svm-手写数字识别",[1096,1159,1162],{"className":1160,"code":1161,"language":1101,"meta":1102},[1099],"import numpy as np\nimport  warnings\nimport random\nwarnings.filterwarnings(\"ignore\")\n\ndef load_digits():\n    X = []\n    y = []\n    line = input()\n    while line:\n        dx = []\n        data = [l for l in line.strip().split(',')]\n        X.append(np.array([np.float(d) for d in data[:-1]]))\n        y.append(np.int(data[-1]))\n        line = input()\n        if '#' in line:\n            break\n    return np.array(X),np.array(y)\n\ndef train_test_split(X,Y,test_size=0.2,random_state=5):\n    n_samples = len(X)\n    assert len(X)==len(Y)\n\n    indices = np.arange(n_samples)\n    random.seed(random_state)\n\n    train_indexs = list(set(random.sample(indices.tolist(),int(n_samples*(1-test_size)))))\n    test_indexs = [k for k in indices if k not in train_indexs]\n    return X[train_indexs,:],X[test_indexs,:],Y[train_indexs],Y[test_indexs]\n\nX,y = load_digits()\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5)\nclass SVC():\n    def __init__(self,X,Y,alpha,steps,reg):\n        self.X = X\n        self.y = Y\n        self.alpha = alpha\n        self.steps = steps\n        self.reg = reg\n        self.model(self.X,self.y,self.alpha,self.steps,self.reg)\n\n    def lossAndGradNaive(self,X,Y,W,reg):\n        dW=np.zeros(W.shape)\n        loss = 0.0\n        num_class=W.shape[0]\n        num_X=X.shape[0]\n        for i in range(num_X):\n            scores=np.dot(W,X[i])\n            cur_scores=scores[int(Y[i])]\n            for j in range(num_class):\n                if j==Y[i]:\n                    continue\n                margin=scores[j]-cur_scores+1\n                if margin>0:\n                    loss+=margin\n                    dW[j,:]+=X[i]\n                    dW[int(Y[i]),:]-=X[i]\n        loss\u002F=num_X\n        dW\u002F=num_X\n        loss+=reg*np.sum(W*W)\n        dW+=2*reg*W\n        return loss,dW\n\n    def lossAndGradVector(self,X,Y,W,reg):\n        dW=np.zeros(W.shape)\n        N=X.shape[0]\n        Y_=X.dot(W.T)\n        margin=Y_-Y_[range(N),Y.astype(int)].reshape([-1,1])+1.0\n        margin[range(N),Y.astype(int)]=0.0\n        margin=(margin>0)*margin\n        loss=0.0\n        loss+=np.sum(margin)\u002FN\n        loss+=reg*np.sum(W*W)\n\n        countsX=(margin>0).astype(int)\n        countsX[range(N),Y.astype(int)]=-np.sum(countsX,axis=1)\n        dW+=np.dot(countsX.T,X)\u002FN+2*reg*W\n        return loss,dW\n\n    def predict(self,X,W):\n        X=np.hstack([X, np.ones((X.shape[0], 1))])\n        Y_=np.dot(X,W.T)\n        Y_pre=np.argmax(Y_,axis=1)\n        return Y_pre\n\n    def accuracy(self,X,Y):\n        Y_pre=self.predict(X,self.W)\n        acc=(Y_pre==Y).mean()\n        return acc\n\n    def model(self,X,Y,alpha,steps,reg):\n        X=np.hstack([X, np.ones((X.shape[0], 1))])\n        W = np.random.randn(10,X.shape[1]) * 0.0001\n        for step in range(steps):\n            loss,grad=self.lossAndGradNaive(X,Y,W,reg)\n            W-=alpha*grad\n        self.W = W\n\nsvc=SVC(X_train,y_train,0.01,25,0.5)\nacc = svc.accuracy(X_test,y_test)\n\n\nprint(\"debug_begin\");\ndef test_acc(acc):\n    res = True if acc>0.85 else False\n    print(res)\nprint(\"debug_end\");\n\ntest_acc(acc)\n",[1104,1163,1161],{"__ignoreMap":1102},[1091,1165,1167],{"id":1166},"svm-梯度下降实现-svm-多分类问题","svm-梯度下降实现 SVM 多分类问题",[1096,1169,1172],{"className":1170,"code":1171,"language":1101,"meta":1102},[1099],"import numpy as np\nimport warnings\n\ndef  load_iris():\n        X  =  []\n        y  =  []\n        line  =  input()\n        while  line:\n            dx  =  []\n            data  =  [l  for  l  in  line.strip().split(',')]\n            X.append(np.array([np.float(d)  for  d  in  data[:-1]]))\n            y.append(np.int(data[-1]))\n            line  =  input()\n            if '#' in line:\n                break\n        return  np.array(X),np.array(y)\n\nx,y = load_iris()\nprint(\"debug_begin\");\ndef test_acc(acc):\n        res = True if acc>=0.9 else False\n        print(res)\nprint(\"debug_end\");\n\ndef normalize_data(data):\n    mean = np.mean(data, axis=0)\n    std = np.std(data, axis=0)\n    for i in range(data.shape[0]):\n        data[i, :] = (data[i, :] - mean) \u002F std\n    return  data\n\ndef convert_to_one_hot(y, C):\n    return np.eye(C)[y.reshape(-1)]\n\nbatchsz = 150\n\ndef obtain_w_via_gradient_descent(x, c, y, penalty_c, threshold = 1e-19, learn_rate = 1e-4):\n    \"\"\" 利用梯度下降法求解如下的SVM问题：min 1\u002F2 * w^T * w + C * Σ_i=1:n（max(0, 1 - y_i * (w^T * x_i + b))）\n    :param x: 训练样本 x = [x_1, x_2, ..., x_i]\n    :param c: 类别数\n    :param y: 样本标签 y = [y_1, y_2, ..., y_c]\n    :param threshold: 梯度下降停止阈值\n    \"\"\"\n    data_num = np.shape(x)[1]\n    feature_dim = np.shape(x)[0]\n    w = np.ones([feature_dim, c], dtype=np.float32)\n    b = np.ones([c, 1], dtype=np.float32)\n    dl_dw = np.zeros([feature_dim, c], dtype=np.float)\n    dl_db = np.zeros([c, 1], dtype=np.float)\n    it = 1\n    th = 0.1\n    while it \u003C 50000 and th > threshold:\n        a = np.tile(b, [1, data_num])\n        ksi = (np.transpose(w) @ x + np.tile(b, [1, data_num])) * y\n        index_martix = ksi \u003C 1\n\n        for class_num in range(c):\n            index_vector = index_martix[class_num, :]\n\n            if True in index_vector:\n                x_c = x[:, index_vector]\n\n                data_num_c = np.shape(x_c)[1]\n                e = np.ones([data_num_c, 1], dtype=np.float)\n                y_c = np.reshape(y[class_num, index_vector], [data_num_c, 1])\n                w_c = np.reshape(w[:, class_num], [feature_dim, 1])\n                b_c = b[class_num]\n\n                dl_dw[:, class_num] = (w_c + 2 * penalty_c * (x_c @ np.transpose(x_c) @ w_c +\n                                                              x_c @ e * b_c -\n                                                              x_c @ y_c))[:, 0]\n                dl_db[class_num, 0] = 2 * penalty_c * (b_c * data_num_c +\n                                                       np.transpose(w_c) @ x_c @ e -\n                                                       np.transpose(y_c) @ e)\n            else:\n                w_c = np.reshape(w[:, class_num], [feature_dim, 1])\n                dl_dw[:, class_num] = w_c[:, 0]\n                dl_db[class_num, 0] = 0\n\n        w_ = w - learn_rate * (dl_dw \u002F np.linalg.norm(dl_dw, ord=2))\n        b_ = b - learn_rate * dl_db\n\n        th = np.sum(np.square(w_ - w)) + np.sum(np.square(b_ - b))\n        it = it + 1\n\n        w = w_\n        b = b_\n\n        y_predict = np.transpose(w) @ x + np.tile(b, [1, data_num])\n        correct_prediction = np.equal(np.argmax(y_predict, 0), np.argmax(y, 0))\n        accuracy = np.mean(correct_prediction.astype(np.float))\n\n    return accuracy\n\nwarnings.filterwarnings(\"ignore\")\n\nx = normalize_data(x)\ny = y.astype(np.int)\ny_onehot = convert_to_one_hot(y,3)\ny_onehot[y_onehot==0]=-1\n\nx = np.transpose(x)\ny_onehot = np.transpose(y_onehot)\nw = np.array([[1,1,1],[1,1,1]])\nb = np.array([[1],[1],[1]])\nacc = obtain_w_via_gradient_descent(x,3,y_onehot,0.5)\n\ntest_acc(acc)\n",[1104,1173,1171],{"__ignoreMap":1102},{"title":1102,"searchDepth":1175,"depth":1175,"links":1176},4,[1177,1183,1184,1185,1186,1187],{"id":1093,"depth":1178,"text":1094,"children":1179},2,[1180,1182],{"id":1109,"depth":1181,"text":1110},3,{"id":1119,"depth":1181,"text":1120},{"id":1129,"depth":1178,"text":1130},{"id":1139,"depth":1178,"text":1139},{"id":1148,"depth":1178,"text":1148},{"id":1157,"depth":1178,"text":1157},{"id":1166,"depth":1178,"text":1167},"md",true,{"uuid":1191,"slots":1192},"a04b3190-ebf6-11f0-9842-5fd805487ccf",{},1,{"title":1085,"description":1102},"posts\u002F2026\u002F2026-01-07-机器学习相关算法",[231,40,32],"HfgTknJh2QEABjxjHK5cv0ij0Av3q4HNvD65zzFkhDg",1790443286542]