Information Gain 计算 python实现

分享关于视觉显著性评估指标的一些代码 分享关于视觉显著性评估指标的一些代码 博客小白兼今年9月准备研一的人工智能小白,第一次发博客,想分享一些之前毕设里用到的视觉显著性评估指标的python代码,包括CC,SIM,AUC,NSS等,要是对大家有一些帮助就最好了。 By:精灵之羽(1032332623)欢迎大神加好友能带飞我呀 代码函数主要有: - 线性相关性(英文全称:Linear Correlation Coeffcent,... 阅读详情



from math import log

def I(*args):
    total = sum(args) + 0.0
    result = 0.0
    for i in args:
        if i == 0:
            result += 0
        else:
            result += i / total * log( i / total, 2)
    return -result

#num表示分类的个数
def E(num, *args):
    if len(args) % num != 0:
        print "Error len(args)"
    result = 0.0
    total = sum(args)
    for x in xrange(len(args) / num):
        k = x * num
        total_up = 0.0 + sum(args[k:k + num])
        result += total_up / total * I(*args[k:k + num])
    return result

def Gain(i, e):
    return i - e

#取个别名
i = I
e = E
g = Gain

if __name__ == "__main__":
    #for example
    print i(9, 5)
    print e(2, 2, 3, 4, 0, 3, 2)




信息增益Information Gain原理与代码实例讲解 引言 信息增益(Information Gain)是信息论和决策树算法中一个重要的概念。它被广泛应用于数据挖掘、特征选择、降维以及机器学习中的决策树构建等领域。信息增益的基本思想是选择能够最大程度减少数据不确定性(即熵)的特征作为分割点,从而提高分类的准确性和效率。 本文旨在深入探讨信息增益的原理,并通过实际代码实例展示其在不同场景下的应用。文 阅读详情

相关推荐

information_gain

information_gain

机器学习|决策树|如何计算信息增益|方法总结

1.计算整体数据集的熵(Initial Entropy) 2.计算在特定属性条件下的条件熵(Conditional Entropy) 3. 计算信息增益(Information Gain)

公众号:快乐变态屋 漂亮大男孩的罗德岛 5396

Vivado IP核与约束文件管理指南:解决OOC警告、COE文件丢失与Block Design复用

本文详细介绍了Vivado IP核与约束文件管理的系统化方法,包括解决OOC警告、COE文件丢失与Block Design复用等常见问题。通过IP核锁定机制、分层约束架构和动态约束技术,提升FPGA工程的健壮性和团队协作效率,特别适合中大型项目开发。

weixin_30887919的博客 430

决策树的构造

递归结束的条件是:程序遍历完所有划分数据集的属性,或者每个分支下的所有实例都具有相同的分类。的所有分支上,如果某个分支下的数据属于同一类型,则当前无序阅读的垃圾邮件已经正确的划分数据分类,无需进一步对数据集进行分割,如果不属于同一类,则要重复划分数据子集,直到所有相同类型的数据均在一个数据子集内。划分数据集,由于特征值可能多于两个,因此可能存在大于两个分支的数据集划分。第一次划分之后,数据将被向下传递到树分支的下一个节点,在这个节点上,我们可以再次划分数据。如果待分类的事务可能划分在多个分类之中,则符合。

2301_79617030的博客 1361

车联网ECU、TSP与TBOX通信流程

对比维度ECU(电子控制单元)BMS(电池管理系统)应用场景传统燃油车 + 新能源汽车仅限新能源汽车核心作用控制整车各系统运行管理动力电池安全与寿命车联网角色数据采集与传输的核心载体提供电池相关的核心数据。

tecoes的博客 1233

Backtrader官方中文文档:第四章Concepts基本概念

官方Concepts章节:https://backtrader.com/docu/concepts/

汇渊科技 2602

SVM算法实现手写数字识别(Sklearn实现)

1、Sklearn.svm学习 数据集下载:trainingDigits训练集下载,testDigits测试集下载 详细数据介绍参看:KNN算法实现手写数字识别 2、代码实现 # -*- coding: UTF-8 -*- import numpy as np from os import listdir from sklearn.svm import SV...

分享实践与思考 2万+

【人工智能 Open AI】程序员怎样提升研发效率?从技术、业务、项目管理等等多个方面来阐述。

程序员要想提升研发效率,需要从技术、业务、项目管理等多方面着手,多靠工具配合实践实现,从而提升研发效率。

AI天才研究院 5527

机器学习复习Day6——决策树

关键是占位数别撞上真实下标——-1、3、4、5 都可以,**2 不行**(2 是"独生"特征的下标)。** 数据:10 朵蘑菇、3 个特征(棕色菌盖 / 细长菌柄 / 独生),标签是**可食(1) / 有毒(0)**。- **熵**:全一种 = 0,一半一半 = 1。公式 `-p1·log₂(p1) - (1-p1)·log₂(1-p1)`,`p1` = 可食比例。- `p1` 是 0 或 1 时 `np.log2` 会算出 `-inf`,`0×-inf = nan`,必须 `else` 兜底给 0。

2503_94114317的博客 542

Unity之OpenXR+XR Interaction Toolkit接入HTC Vive

目前VR领域,最流行的设备要当属HTC VIVE了。以前在Unity端接入HTC VIVE设备时,都是通过SteamVR+VRTK来接入的。但是随着Unity的版本升级和OpenXR标准的流行,再加上VR设备的逐渐增多。SteamVR+VRTK的方式已经无法更好的满足大家的需求。

TxNet 4137

关于 Nginx 监听地址 0.0.0.0 的详细解释

0.0.0.0在Nginx配置中表示监听服务器所有网络接口(包括公网IP、内网IP和本地回环地址),这是默认配置。当使用listen 80;时,Nginx会接受通过服务器任何IP地址的80端口访问请求。相比只监听特定IP,这种配置更通用,但也意味着服务会对外网开放,需注意安全风险。可通过netstat命令验证监听状态,显示0.0.0.0:80即表示正确配置。

weixin_43674738的博客 1566

Information Gain|信息增益

信息增益是决策树中衡量特征对分类贡献的重要指标,它基于熵来评估数据集的不确定性,通过计算分裂前后熵的减少量,反映某个特征对提高分类有序性的作用。信息增益越大,说明该特征越能有效区分数据,提升模型的预测准确性,因此常被选作分裂节点的依据。欢迎来 rn.berlinlian.cn 进行交流。

m0_74462934的博客 975

高熵合金AlCoCrFeNi/金刚石摩擦案例代码

本文介绍金刚石与高熵合金AlCoCrFeNi摩擦的案例。 在之前的文章中,介绍过使用fix indent命令实现虚拟球的摩擦,本文介绍使用金刚石实体球实现高熵合金摩擦的方法。 主要的模拟过程如下: (1)基体建模 建使用原子替换法获得高熵合金初始模型,升温到3000K驰豫后,冷却至300K,获得平衡组织。 (2)摩擦球建模 在高熵合金平衡组织的模型中添加金刚石摩擦球,使用change_box命令扩大box尺寸,添加金刚石摩擦球,并设置混合力场。 (3)摩擦过程 摩擦球下压一定深度后,沿y方向进行摩擦,摩擦

lammps_jiayou的博客 2900

信息增益(Information Gain)

信息增益是决策树选择分裂特征的核心指标,通过计算特征分裂前后熵的减少量来评估其分类价值。本文以"耳朵形状"特征为例详细演示了信息增益的计算流程:先计算父节点熵(1),再按特征取值划分样本集并计算子节点熵(尖的0.72,下垂的0.72),最后得到信息增益0.28。对比计算"脸型"特征也得到相同结果。关键点在于特征分裂后子节点加权熵之和越小,说明该特征分类能力越强。决策树选择信息增益最大的特征进行分裂,从而实现最佳分类效果。

StarPrayers.的博客 900

Unreal5从入门到精通之如何在VR中使用3DUI

前面我们讲过《Unreal5从入门到精通之UMG的使用》一般制作游戏时,UI都是添加到屏幕视窗上面的,但是在制作VR时,我们往往需要制作一个3D的UI,放置在场景中,然后使用手柄的射线来和UI进行交互。今天我们就来讲解下,如何在VR中创作和交互3DUI首次操作会感觉好复杂,多多练习,当你熟悉了UE蓝图的操作后会发现,这只是一个常规的蓝图操作而已。祝大家在虚幻的学习过程中非常顺利。希望这篇博客对你有所帮助。

TxNet 1985

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

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

详解:ID3算法 ― 信息增益 (Information Gain)(初学者)

本文介绍了ID3决策树算法中基于信息增益的特征选择方法。通过计算天气、温度、湿度和有风四个特征对"是否外出打球"分类结果的信息增益,发现天气特征的信息增益最大(0.247),其次是湿度(0.151)、有风(0.048)和温度(0.029)。信息增益衡量了特征减少系统不确定性的能力,数值越大表示该特征对分类决策越重要。因此,在构建决策树时,算法将优先选择信息增益最大的天气特征作为第一个划分节点。

2301_79749195的博客 3440

深度学习工具包 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")

python get score gain_什么是“熵和信息增益”?(What is “entropy and information gain”?)...

什么是“熵和信息增益”?(What is “entropy and information gain”?)我正在读这本书( NLTK ),令人困惑。 熵被定义为 :熵是每个标签的概率乘以同一标签的对数概率的总和在文本挖掘方面如何应用熵和最大熵 ? 有人可以给我一个简单,简单的例子(视觉)吗?I am reading this book (NLTK) and it is confusing. Ent...

weixin_36082388的博客 166

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

上一篇: Python 随想一些有用feature
下一篇: Python 50行代码实现代理服务器(加强版)
junfeng_feng
博客等级 码龄18年 13粉丝 10原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值