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)
分享到:
相关推荐
Spark for Python Developers aims to combine the elegance and fl...Third, gain insights from the collected data. Fourth, stream live data and process it in real time. Finally, visualize the information.
Exploit the Remote File Inclusion to gain administrative access to systems with Python and other scripting languages Crack an organization's Internet perimeter and chain exploits to gain deeper access...
This book begins with an introduction to chatbots where you will gain vital information on their architecture. You will then dive straight into natural language processing with the natural language ...
this book will help you gain practical skills in Natural Language Processing using the Python programming language and the Natural Language Toolkit (NLTK) open source library., If you're interested in...
You will gain hands on experience with complex data types including text, images, and graphs. You will also discover object detection using Deep Neural Networks, which is one of the big, difficult ...
Gain insights into the current and budding research topics of NLP This is a comprehensive step-by-step guide to help students and researchers create their own projects based on real-life applications ...
Gain an insight on algorithms that run inference Explore parameter estimation in Bayes nets with PyMC sampling Understand the complexity of running inference algorithms in Bayes networks Discover ...
The next step in the information age is to gain insights from the deluge of data coming our way. Data mining provides a way of finding this insight, and Python is one of the most popular languages for...
Gain a fundamental understanding of Python’s syntax and features with the second edition of Beginning Python, an up–to–date introduction and practical reference. Covering a wide array of Python–...
Rather than simply using words for descriptions, graphics are very effective in transferring information. An abstract concept can materialize through the use of graphics in order to improve the ...
This book begins with an introduction to chatbots where you will gain vital information on their architecture. You will then dive straight into natural language processing with the natural language ...
information_gain
CUDA_VISIBLE_DEVICES = 3 python corechain.py -model slotptr -device cuda -dataset lcquad -pointwise False 下载手套 wget 将其保存到资源文件夹中将其解压缩 使用Anaconda安装(仍然需要对其进行测试) ...
# 计算数据集的信息熵(Information Gain)增益函数(机器学习实战中信息熵叫香农熵) def calcInfoEnt(dataSet):#本题中Label即好or坏瓜 #dataSet每一列是一个属性(列末是Label) numEntries = len(dataSet) #每一行是...
To get the most out of this book, you will need to know some linear algebra and some Python, and have a basic knowledge of machine learning concepts. What You Will Learn Gain an understanding of the...
Build three web applications from the ground up using the powerful Python micro framework, Flask. Dynamically display data to your viewers, based on their requests Store user and static data in SQL ...