亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? entropy.java

?? 本程序是用java語言編寫的數據挖掘分類算法中的決策樹分類方法c4.5程序代碼
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
        return H.value;
    }
    
    /** Computes conditional entropy of the label given attribute X. From Ross,
     * Conditional entropy is defined as:                                          <BR>
     *             H(Y|X) = sum_x H(Y|X=x)*P(X=x).                            <BR>
     *                    = sum_x (-sum_y p(Y=y|X=x)log p(Y=y|X=x)) * P(X=x)  <BR>
     *             now derive Pagallo & Haussler's formula                    <BR>
     *                    = -sum_{x,y} p(Y=y, X=x) log p(Y=y|X=x)             <BR>
     *             Here we estimate p(Y=y, X=x) by counting, but if we
     *               have priors on the probabilities of the labels, then     <BR>
     *               p(x,y) = p(x|y)*p(y) = count(x,y)/s(y)* prior(y)         <BR>
     *               and p(x) = sum_y prior(y) count(x,y)/s(y).               <BR>
     *
     *             By counting we get the following:                          <BR>
     *             -sum_{x,y} num(Y=y,X=x)/num-rec * log num(Y=y,X=x)/num(X=x)
     *
     * @param instList The instance list over which conditional entropy is calculated.
     * @param attrNumX The number of the attribute for which conditional entropy is requested.
     * @return The conditional entropy.
     */
    public static double cond_entropy(InstanceList instList, int attrNumX) {
        return cond_entropy(instList.counters().value_counts()[attrNumX],
        instList.counters().attr_counts()[attrNumX],
        instList.total_weight());
    }
    
    /** Compute the mutual information which is defined as I(Y;X) = H(Y) - H(Y|X). Some
     * researchers like Quinlan call this "gain." This is the amount of information
     * gained about the category value of an instance after we test the variable X.
     *
     * @param ent Entropy value.
     * @param splitAndLabelDist Distributions over each split and label pair.
     * @param splitDist The distribution over splits.
     * @param totalWeight Total weight of the Instances trained on.
     * @return The mutual information value.
     */
    public static double mutual_info(double ent,double[][] splitAndLabelDist,
    double[] splitDist, double totalWeight) {
        double condEntropy = Entropy.cond_entropy(splitAndLabelDist, splitDist,
        totalWeight);
        DoubleRef mi = new DoubleRef(ent - condEntropy);
        // Mutual information should never be negative; the following
        //   accounts for possible numerical representation errors.
        MLJ.clamp_above(mi, 0, "mutual_info: negative values not allowed");
        return mi.value;
    }
    
    /** Compute the mutual information which is defined as I(Y;X) = H(Y) - H(Y|X). Some
     * researchers like Quinlan call this "gain." This is the amount of information
     * gained about the category value of an instance after we test the variable X.
     * @param instList The instance list over which mutual information is calculated.
     * @param attrNumX The number of the attribute for which mutual information is requested.
     * @return The mutual information value.
     */
    public static double mutual_info(InstanceList instList, int attrNumX) {
        if (instList.counters().attr_counts()[attrNumX] == null)
            Error.fatalErr("entropy::mutual_info: attribute "+attrNumX+
            " is not nominal (counts array is NULL)");
        
        double ent = entropy(instList.counters().label_counts(),
        instList.total_weight());
        return mutual_info(instList, ent, attrNumX);
    }
    
    /** Compute the mutual information which is defined as I(Y;X) = H(Y) - H(Y|X). Some
     * researchers like Quinlan call this "gain." This is the amount of information
     * gained about the category value of an instance after we test the variable X.
     * @param instList The instance list over which mutual information is calculated.
     * @param ent Entropy value.
     * @param attrNumX The number of the attribute for which mutual information is requested.
     * @return The mutual information value.
     */
    public static double mutual_info(InstanceList instList,
    double ent, int attrNumX) {
        if (instList.counters().attr_counts()[attrNumX] == null)
            Error.fatalErr("entropy::mutual_info: attribute "+attrNumX+
            " is not nominal (counts array is NULL)");
        
        return mutual_info(ent,
        instList.counters().value_counts()[attrNumX],
        instList.counters().attr_counts()[attrNumX],
        instList.total_weight());
    }
    
    
    /** Builds the distribution arrays necessary for calculating conditional entropy for
     * nominal attributes. All of the splitAndLabelDist arrays of the Instance Lists are
     * concatenated. The unaccounted instances allow the list of nodes to be partial,
     * i.e., not to contain all instances. The split will be created so that the
     * unaccounted instances are in an extra split with the same label, so that the
     * entropy will be decreased correctly as if they were in a pure node.
     *
     * @param currentLevel The list of instances in the current partition for which a split is being
     * determined.
     * @param attrNum The number of the attribute for which mutual information is requested.
     * @return The distribution over splits.
     */
    static public double[] build_nominal_attr_split_dist(InstanceList[] currentLevel,
    int attrNum) {
        return build_nominal_attr_split_dist(currentLevel,attrNum,0);
    }
    
    /** Builds the distribution arrays necessary for calculating conditional entropy for
     * nominal attributes. All of the splitAndLabelDist arrays of the Instance Lists are
     * concatenated. The unaccounted instances allow the list of nodes to be partial,
     * i.e., not to contain all instances. The split will be created so that the
     * unaccounted instances are in an extra split with the same label, so that the
     * entropy will be decreased correctly as if they were in a pure node.
     *
     * @param currentLevel The list of instances in the current partition for which a split is being
     * determined.
     * @param attrNum The number of the attribute for which mutual information is requested.
     * @param unaccountedWeight Weight that is not accounted for in the list of instances.
     * @return The distribution over splits.
     */
    static public double[] build_nominal_attr_split_dist(InstanceList[] currentLevel,
    int attrNum, double unaccountedWeight) {
        MLJ.ASSERT(currentLevel[0]!= null,"Entropy.build_nominal_attr_split_dist:currentLevel[0]== null.");
        Schema schema = currentLevel[0].get_schema();
        int numInstLists = currentLevel.length;
        int numAttrValues = schema.num_attr_values(attrNum);
        
        MLJ.ASSERT(numInstLists > 0,"Entropy.build_nominal_attr_split_dist:numInstLists <= 0");
        MLJ.ASSERT(numAttrValues > 0,"Entropy.build_nominal_attr_split_dist:numAttrValues <= 0");
        
        int unaccnt_wght_col = (unaccountedWeight > 0)? 1 : 0;
        double[] splitDist = new double[numInstLists * (numAttrValues + 1) + unaccnt_wght_col];
        int countSplitDist = Globals.UNKNOWN_CATEGORY_VAL;
        
        for (int instListCount = 0; instListCount < numInstLists; instListCount++) {
            MLJ.ASSERT(currentLevel[instListCount] != null,"Entropy.build_nominal_attr_split_dist:currentLevel[instListCount] == null");
            for (int attrCount = Globals.UNKNOWN_CATEGORY_VAL; attrCount < numAttrValues;
            attrCount++, countSplitDist++) {
                BagCounters bc = currentLevel[instListCount].counters();
                splitDist[countSplitDist] = bc.attr_counts()[attrNum][attrCount];
            }
        }
        if (unaccountedWeight > 0) {
            MLJ.ASSERT(countSplitDist == splitDist.length,"Entropy.build_nominal_attr_split_dist:countSplitDist != splitDist.length");
            splitDist[countSplitDist] = unaccountedWeight;
        }
        return splitDist;
    }
    
    
    /** Compute the J-measure. See papers by Goodman and Smyth, such as Data
     * Engineering, v.4, no.4, pp.301-316, 1992. The J-measure summed over all
     * values of x gives info-gain. The J-measure is                               <BR>
     * sum_y p(x,y)log(p(x,y)/(p(x)p(y)))                                          <BR>
     * 1/n * sum_y n(x,y)log(n(x,y)*n/(n(x)n(y)))                                  <BR>
     * Used in t_entropy.java.
     *
     * @return The j-measure value.
     * @param splitAndLabelDist Distributions over each split and label pair.
     * @param splitDist The distribution over splits.
     * @param labelCounts Counts of each label found in the data.
     * @param x The x value for the j-measure equation.
     * @param totalWeight Total weight of all data.
     */
    
    public static double j_measure(double[][] splitAndLabelDist,
    double[] splitDist, double[] labelCounts,
    int x, double totalWeight) {
        MLJ.verify_strictly_greater(totalWeight, 0, "j_measure: totalWeight is "+
        "too small");
        
        DoubleRef j = new DoubleRef();
        for (int y = 0;
        y < splitAndLabelDist.length; y++) {
            double num_xy = splitAndLabelDist[y][x];
            double num_x  = splitDist[x];
            double num_y  = labelCounts[y];
            if (!MLJ.approx_equal(num_xy, 0.0)) { // beware of log(0)
                if (Globals.DBG) MLJ.ASSERT((num_x > 0 && num_y > 0),"Entropy.j_measure: num_x <= 0 || num_y <= 0");
                j.value += num_xy *
                log_bin(totalWeight*(num_xy)/(num_x * num_y));
            }
        }
        j.value /= totalWeight; // We know this won't be division by zero.
        
        // Allow for possible numerical representation errors.
        MLJ.clamp_above(j, 0, "j_measure: negative j-measure not allowed");
        
        return j.value;
    }
    
    /** Compute the J-measure. See papers by Goodman and Smyth, such as Data
     * Engineering, v.4, no.4, pp.301-316, 1992. The J-measure summed over all
     * values of x gives info-gain. The J-measure is                               <BR>
     * sum_y p(x,y)log(p(x,y)/(p(x)p(y)))
     * 1/n * sum_y n(x,y)log(n(x,y)*n/(n(x)n(y)))                                  <BR>
     * Used in t_entropy.java.
     *
     * @param instList The list of Instances over which a j measure is to be
     * calculated.
     * @param attrNumX The number of attributes in the Schema of the Instances
     * supplied.
     * @param x The x value for the j-measure equation.
     * @return The j-measure value.
     */
    public static double j_measure(InstanceList instList, int attrNumX, int x) {
        return j_measure(instList.counters().value_counts()[attrNumX],
        instList.counters().attr_counts()[attrNumX],
        instList.counters().label_counts(), x,
        instList.total_weight());
    }
    
    
    /** Builds columns of real values and their associated label values. Invokes
     * InstanceList's transpose function to provide a single column for the passed
     * attribute number, sorts it, and returns the columns to the caller. The second
     * calling argument, if set to an attribute index, results in a single column
     * being transposed and sorted. When set to UNDEFINED_INT, all columns are
     * so treated.
     * @param instList The instance list containing the instance values for the attribute.
     * @param attrNum The number of the attribute for which the real and label column is
     * requested.
     * @return The columns of real values and their associated labels, organized by attribute.
     */
    public static RealAndLabelColumn[] build_real_and_label_columns(
    InstanceList instList, int attrNum) {
        // We initialize the array to FALSE, except for any element(s)
        //   we want to get the RealAndLabelColumn for, which is/are set to TRUE.
        boolean initializer = (attrNum == Globals.UNDEFINED_INT) ? true : false;
        boolean[] transp = new boolean[instList.get_schema().num_attr()];
        Arrays.fill(transp, initializer);
        if (attrNum != Globals.UNDEFINED_INT)
            transp[attrNum] = true;
        RealAndLabelColumn[] columns = instList.transpose(transp);
        
        // If a particular column was requested, check that it was transposed.
        if (attrNum != Globals.UNDEFINED_INT)
            if (columns[attrNum] != null)
                columns[attrNum].sort();
            else
                Error.fatalErr("build_real_and_label_columns: for attribute " +attrNum
                +", no column was built to sort");
        else
            for (int x = 0; x < instList.get_schema().num_attr(); x++)
                if (columns[x] != null)
                    columns[x].sort();
        return columns;
    }
    
    /** Builds a column of real values and their associated label values for the given
     * attribute. Invokes InstanceList's transpose function to provide a single column
     * for the passed attribute number, sorts it, and returns the columns to the caller.
     * The second calling argument, if set to an attribute index, results in a single
     * column being transposed and sorted. When set to UNDEFINED_INT, all columns are
     * so treated.
     * @param instList The instance list containing the instance values for the attribute.
     * @param attrNum The number of the attribute for which the real and label column is
     * requested.
     * @return The column of real values and their associated labels.
     */
    public static RealAndLabelColumn build_real_and_label_column(InstanceList
    instList, int attrNum) {
        RealAndLabelColumn[] columns = build_real_and_label_columns(instList, attrNum);
        // We want to pass the sorted column back to the caller, but delete
        //   the rest of the array.  Save a reference to the single desired
        //   column, and set the entry in the array that points to it to NULL so
        //   that when the array's deleted, the column isn't.  The caller must
        //   delete the single column.
        RealAndLabelColumn sortedColumn = columns[attrNum];
        columns[attrNum] = null;
        columns = null;
        return sortedColumn;
    }
    
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
懂色av一区二区三区蜜臀| 日韩欧美精品在线视频| 日韩一区二区三区电影| 中文字幕日韩欧美一区二区三区| 日韩av网站免费在线| 不卡大黄网站免费看| 欧美一卡二卡在线| 亚洲欧美一区二区三区孕妇| 国产一区视频在线看| 欧美午夜精品久久久| 综合色天天鬼久久鬼色| 国产一区二三区| 91精品国产综合久久蜜臀| 亚洲免费观看高清完整| 成人动漫在线一区| 久久新电视剧免费观看| 美女www一区二区| 欧美日韩一区二区欧美激情| 亚洲欧美在线另类| 国产成人av电影在线| 欧美精品一区二区三区蜜桃| 日本三级韩国三级欧美三级| 欧美日韩第一区日日骚| 亚洲精品国产精华液| 99国产精品一区| 日韩毛片一二三区| jizzjizzjizz欧美| 欧美国产日韩在线观看| 福利一区在线观看| 国产女人水真多18毛片18精品视频 | 久久综合色鬼综合色| 久久se这里有精品| 日韩视频一区二区三区在线播放| 日韩精品免费视频人成| 欧美精品久久99| 青青草国产成人av片免费| 欧美一级片在线| 久久99国内精品| 国产喂奶挤奶一区二区三区 | 午夜影视日本亚洲欧洲精品| 色综合中文字幕| 亚洲高清免费在线| 69av一区二区三区| 久久99最新地址| 国产欧美综合色| 91麻豆视频网站| 亚洲777理论| 欧美一级高清大全免费观看| 韩国v欧美v日本v亚洲v| 国产日韩欧美电影| 色婷婷av一区二区三区gif| 亚洲最大的成人av| 欧美一二三区在线| 国产成人8x视频一区二区 | 亚洲制服欧美中文字幕中文字幕| 欧美午夜一区二区| 激情综合色播五月| 亚洲国产电影在线观看| 欧美午夜片在线看| 久久99国产乱子伦精品免费| 中文字幕一区日韩精品欧美| 欧美调教femdomvk| 国产一区二区三区在线观看精品 | 亚洲成a人片在线不卡一二三区| 91精品国产综合久久久久久久| 精品亚洲成av人在线观看| 国产精品毛片大码女人| 欧美电影在线免费观看| 激情综合五月婷婷| 亚洲一区二区五区| 久久噜噜亚洲综合| 欧美日韩另类一区| 国产成人av在线影院| 婷婷六月综合网| 国产精品丝袜91| 欧美tk丨vk视频| 欧美一a一片一级一片| 国产老肥熟一区二区三区| 亚洲国产另类av| 国产精品久久综合| 精品国产91久久久久久久妲己| 色噜噜狠狠色综合中国| 国内精品写真在线观看| 一区二区三国产精华液| 日本一区二区三区视频视频| 91精品福利在线一区二区三区 | 国产午夜亚洲精品不卡| 在线一区二区三区四区| 国产福利精品导航| 人人精品人人爱| 亚洲综合999| 亚洲三级小视频| 国产精品国产三级国产a| 久久综合视频网| 精品美女被调教视频大全网站| 91一区二区在线| www.久久久久久久久| 国产aⅴ精品一区二区三区色成熟| 婷婷国产v国产偷v亚洲高清| 一区二区免费在线| 亚洲天堂免费看| 国产精品久99| 国产精品国产三级国产| 国产日产欧美一区二区视频| 欧美精品一区二区三区高清aⅴ| 欧美日韩久久不卡| 91久久精品国产91性色tv| 99精品久久久久久| 北条麻妃一区二区三区| 成人精品鲁一区一区二区| 国产一区二区三区av电影| 国产揄拍国内精品对白| 激情小说欧美图片| 国产在线一区二区| 久久电影国产免费久久电影| 免费在线看一区| 捆绑紧缚一区二区三区视频| 久久er99精品| 精品制服美女丁香| 国产精品77777| 成人av片在线观看| 色丁香久综合在线久综合在线观看| 成人av资源在线观看| 91在线视频在线| 日本高清不卡在线观看| 欧美日韩精品久久久| 欧美一区二区久久久| 久久久久九九视频| 国产精品久久久久7777按摩 | 国产精品久久久久久久久搜平片 | 久久理论电影网| 欧美激情一区二区在线| 亚洲久本草在线中文字幕| 亚洲成人午夜影院| 久久99国产精品免费网站| 成人免费看视频| 欧美专区在线观看一区| 日韩免费视频一区| 亚洲国产成人一区二区三区| 夜夜亚洲天天久久| 久久福利视频一区二区| thepron国产精品| 337p亚洲精品色噜噜狠狠| 久久久99久久精品欧美| 亚洲精品高清在线观看| 久久99热这里只有精品| 91在线视频播放| 日韩欧美一级二级三级| 国产精品免费视频网站| 五月天欧美精品| 国产sm精品调教视频网站| 在线观看免费一区| 久久亚洲影视婷婷| 亚洲国产欧美另类丝袜| 国产精品99精品久久免费| 欧美日韩精品一区视频| 国产欧美综合色| 青青草97国产精品免费观看| eeuss鲁片一区二区三区在线观看| 欧美日韩aaaaa| 中文字幕在线观看不卡| 激情综合色播激情啊| 91福利国产精品| 国产色91在线| 日本美女一区二区三区| 成年人午夜久久久| 精品黑人一区二区三区久久| 亚洲一区二区三区四区五区中文 | 蜜臀av性久久久久蜜臀aⅴ| av高清不卡在线| 久久久亚洲精华液精华液精华液| 亚洲一二三四区| 成人激情免费网站| 欧美xxxxx裸体时装秀| 婷婷中文字幕一区三区| 日本精品免费观看高清观看| 欧美高清一级片在线观看| 蜜臀av性久久久久蜜臀aⅴ| 精品视频资源站| 亚洲视频资源在线| 国产91丝袜在线播放九色| 精品少妇一区二区三区在线播放| 夜夜嗨av一区二区三区四季av| 国产999精品久久| 久久先锋影音av| 久久99热99| 日韩免费观看高清完整版| 日韩av在线发布| 欧美精品 日韩| 亚洲成人自拍网| 欧美另类高清zo欧美| 亚洲国产另类精品专区| 欧美色精品在线视频| 亚洲一区在线观看网站| 欧美在线观看视频一区二区| 一区二区视频在线| 91在线免费看| 一区二区三区在线免费播放| 色综合咪咪久久| 亚洲精品免费在线播放|