上传者: 38517113 
                                    |
                                    上传时间: 2021-10-26 22:02:10
                                    |
                                    文件大小: 137KB
                                    |
                                    文件类型: -
                                
                            
                                
                            
                                实例如下:
# -*- coding:utf-8 -*-
from numpy import *
import numpy as np
import pandas as pd
from math import log
import operator
#计算数据集的香农熵
def calcShannonEnt(dataSet):
  numEntries=len(dataSet)
  labelCounts={}
  #给所有可能分类创建字典
  for featVec in dataSet:
    currentLabel=featVec[-1]
    if currentLabel n