标签传播算法LPA:半监督学习解决标注数据不足的完整实战指南

半监督—标签传播算法 半监督学习:样本集部分有标注,部分无标注(常远大于有标注样本) 标签传播算法(LabelPropagation):物以类聚的思想,把没有标注的样本和有标注的样本进行比较,相似度高的标为同标注,会优先标注离有标注近的无标注样本,然后再进行传播。要求未标注样本的标注值是-1。 以Iris数据集(山鸢花)为例 import numpy as np from sklearn import data... 阅读详情

直接从问题出发,不绕弯子。我去年做一个信贷风控项目时,标好标签的样本只有两千多条,剩下的二十多万条全是没标注的。用纯监督学习,模型很快过拟合,在验证集上AUC只有0.68。后面换成Label Propagation算法,把这些未标注数据全部拉进图里参与传播,AUC直接涨到0.81。那一刻起我开始相信,标签不够时,不是只有"人工标注"和"简单半监督"两条路,基于图论的标签传播思路,确实能在低标注率场景下把模型救回来。

这篇文章就把Label Propagation算法(后面统一叫LPA)从头到尾拆开讲清楚:它怎么把样本变成图、标签怎么在图上传播、背后的数学原理是什么、怎么用Python快速落地,以及我在真实项目里踩过的坑。适合正在做分类任务但标注样本不够的人,也适合想系统理解半监督学习原理、不满足于只会调库的读者。

1. 一个反直觉的现实:标注样本很少时,LPA反而比纯监督更稳

很多初学者有个误解:机器学习嘛,就是要喂大量标注数据,数据不够就扛不住。但真实业务里,标注数据恰恰是最贵的资源,尤其在医疗影像、金融风控、工业质检这些领域,请专家标一条数据可能要几十块钱,标注周期还可能拖一两周。这时候再纠结"有监督学习+SOTA模型"完全是死路。

1.1 无标注数据里的"隐性知识"如何被利用

LPA和传统监督学习的本质区别,在于它不只看标注样本,还会去挖掘未标注样本之间、以及未标注样本与标注样本之间的结构关系。它把所有的数据点(不管是标注的还是未标注的)看成一张图上的节点,节点之间用边连接,边的权重体现样本相似度。标签信息就从那些已知节点出发,沿着边逐步扩散到未知节点。

这个过程可以类比成一个班上只有5个人知道考试答案,其他人不知道。但如果坐得近的人通常成绩相近,那么那5个人把答案悄悄告诉邻桌,邻桌再告诉更远的同桌,最终全班都能知道个大概。LPA干的就是这件事,只不过"坐得近"被定义成了特征空间中的相似性。

1.2 聚类假设与流形假设:LPA成立的底层逻辑

LPA有效,依赖两个经典假设:

  • 聚类假设(Cluster Assumption) :同一类别的样本在特征空间中往往聚成团,决策边界应该尽量穿过低密度区域。
  • 流形假设(Manifold Assumption) :高维数据实际上分布在一个低维流形附近,样本点在流形上的邻近关系比欧氏距离更能反映语义相似性。

LPA在图结构上做传播,天然契合这两个假设。只要图建得好,相似样本之间就会形成高权重边,标签沿着边的传播就等价于"让同类样本的标签趋于一致",这比直接在原始特征空间里训练一个线性分类器要灵活得多。

2. 数据变图纸:LPA的图构建与标签传播全流程拆解

LPA看起来不复杂,但落地时每一步都有讲究。下面按流程拆开讲,图怎么建、权重怎么算、标签怎么传播、迭代怎么停,逐个说清楚。

2.1 图构建:三种方式与选型依据

要做标签传播,第一步是把样本集变成图。常见的图构建方式有三种:

构建方式 做法 适用场景 主要风险
全连接图 每两个节点之间都连边,权重用RBF核函数计算 样本量小(千级以内),特征维度不高 计算量O(n²),样本多时直接爆炸;容易把不同簇连在一起
K近邻图 每个节点只连接最近K个邻居,边权为1或相似度 通用场景,sklearn默认支持 K太小容易断图,K太大会产生"短路"边
ε-半径图 节点与距离小于ε的节点连边 有明确距离意义的数据 ε需要人工反复调试,不同区域密度差异大时很难选

我个人的习惯是:数据量小于5000时优先全连接+RBF核,因为信息保留完整;数据量大时用KNN图,兼顾质量和计算效率。还要强调一点, 建图前必须做特

Label Propagation标签传播算法原理与代码实例讲解 Label Propagation标签传播算法原理与代码实例讲解 关键词:标签传播算法, 半监督学习, 图算法, 社区发现, 分类, 机器学习 1. 背景介绍 在机器学习领域,我们常常面临这样的情况:海量的数据 阅读详情

相关推荐

28. BI - 图论工具和算法, 社区发现以及最短路径

图,不仅仅是一个排序的问题,还有很多工具可去使用. 前几节课中给大家介绍的NetworkX, 在这个工具箱里也存在着除了PageRank以外的一些方法. 咱们应该很多人都用过高德地图或者百度地图, 在图上面最经典的一个算法就是求路径.

茶桁专栏 2056

半监督+标签传播算法

半监督+标签传播算法 sklearn中LabelPropagation和LabelSpreading的区别? LabelSpreading model is similar to the basic Label Propagation algorithm, but uses affinity matrix based on the normalized graph Laplacian and soft clamping across the labels. LPA 算法有很多的...

data+scenario+science+insight 499

半监督学习在文本数据处理中的应用

1. 背景介绍 1.1 文本数据处理的挑战 随着互联网的普及和信息技术的飞速发展,文本数据的产生和传播呈现出爆炸式增长。如何有效地处理这些海量的文本数据,从中挖掘有价值的信息,已经成为计算机科学领域的一个重要课题。然而,文本数据处理面临着诸多挑战,如数据的高维度、稀疏性、噪声以及标注数据的稀缺等。

AI天才研究院 231

别再只用跳层连接了!手把手教你用DASI和MDCR模块提升红外小目标检测精度

本文详细介绍了如何利用DASI和MDCR模块提升红外小目标检测精度。通过分析传统跳层连接的缺陷,提出维度感知的特征选择性融合(DASI)和多尺度感受野精炼器(MDCR)的创新方案,显著提升小目标检测性能。实验证明,该方法在多个场景下AP@0.5提升达15.4%,特别适用于安防监控和遥感图像分析。

weixin_28715081的博客 225

基于OpenAI Agents构建多智能体工作流:从原理到实战

多智能体系统(Multi-Agent System)是人工智能领域的重要分支,它通过多个智能体(Agent)的协作与交互,解决单一智能体难以处理的复杂任务。其核心原理在于将任务分解、分配与协调,每个智能体具备特定能力,通过通信机制实现信息共享与决策协同。在工程实践中,多智能体框架的价值在于提升任务处理效率、增强系统鲁棒性,并支持模块化开发。典型的应用场景包括自动化工作流编排、复杂问题求解以及人机协同交互。本文以OpenAI Agents SDK为例,深入探讨如何利用其提供的智能体(Agent)、会话(Ses

weixin_28725959的博客 608

【重磅更新】CT/MRI LI-RADS 2024:肝细胞癌局部区域治疗后反应评估的核心突破与临床实践指南

减少过度治疗:辐射 LRT 的 Nonprogressing 类别避免了 “持续强化 = 存活” 的误判,降低不必要的再治疗风险;提高检出效率:非辐射 LRT 的辅助特征升级减少了 Equivocal 比例,更早识别存活肿瘤;统一评估语言:标准化的分类标准为放射科、肝病科、肿瘤科、肝移植科的多学科协作(MDT)提供了统一 “沟通工具”,助力治疗方案的精准制定。

楚山之石的博客 1232

无人机蜂群作战设计技术详解

构建防御网络,拦截敌方无人机或导弹;无人机蜂群作战设计技术是一种创新的军事应用概念,它基于生物仿生学原理,通过先进的通信技术、自主导航与决策算法,将大量小型、低成本、功能各异的无人机组织成一个高度协同的群体,以执行复杂多样的军事任务。无人机蜂群作战的概念源于自然界中蜜蜂、蚂蚁等生物群体的行为模式,这些生物群体通过简单的个体间的信息交互和分工协作,能够完成远远超出单一个体能力的复杂任务。其中,无人机群体是执行任务的主体,指挥控制系统负责任务分配和决策,通信数据链则保障无人机群体与指挥控制系统之间的信息交换。

专注多旋翼、复合翼无人机技术研究,从事低空经济行业。 2220

做cellchat画图时自环的角度颠倒,如何解决?

🏆本文收录于 《全栈 Bug 调优(实战版)》 专栏。专栏聚焦真实项目中的各类疑难 Bug,从成因剖析 → 排查路径 → 解决方案 → 预防优化全链路拆解,形成一套可复用、可沉淀的实战知识体系。无论你是初入职场的开发者,还是负责复杂项目的资深工程师,都可以在这里构建一套属于自己的「问题诊断与性能调优」方法论,助你稳步进阶、放大技术价值 。

**My Coding Family** 469

FT2004(D2000)开发实战之AMD R5 230显卡驱动适配

AMD R5 230显卡驱动适配

嵌入式Linux 3217

详解AUTOSAR:DaVinci Configurator导入ARXML配置(拓展篇—2)

DaVinci Configurator导入ARXML配置。

不脱发的程序猿 3345

excel 如何自动调整行间距 vba

EXCEL是一个非常使用的软件,虽然我们平时仅使用他做一些报表,仅此而已;我在工作中,由于很懒,不愿意做考试重复的工作,就想着使用vba的宏来完成重复的工作,这样就能省出一部分的时间来了。本人不喜欢在博客里面写以下教程类的东西,我的理念是将工作中的痛点的解决办法分享出来,以解决问题为主。

sixtome 1317

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

上一篇: Spark 3.x结合Hudi写入报错排查:版本兼容与配置实战
下一篇: system_prompts_leaks:大模型提示词泄露原理与防御实践
王释易
博客等级 码龄10年 61粉丝 1万+原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址