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

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

?? entropy.java

?? 本程序是用java語言編寫的數據挖掘分類算法中的決策樹分類方法c4.5程序代碼
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
     * @param labelCount	The count of each label found in the data.
     * @return The entropy for the supplied label counts.
     */
    public static double entropy(double[] labelCount) {
        double sum = MLJArray.sum(labelCount);
        if (MLJ.approx_equal(sum, 0.0))
            return Globals.UNDEFINED_REAL;
        return entropy(labelCount, sum);
    }
    
    /** Compute the entropy H(Y) for label Y. Giving us an InstanceList forces counters.
     * If you don't give us the total instances, we count (slightly less efficient).
     * Entropy without the sum acts a bit differently by allowing nodes with 0
     * instances and returning entropy -1. The reason is that the caller shouldn't be
     * required to compute the sum just for this.
     *
     * @param labelCount	The count of each label found in the data.
     * @param totalInstanceWeight	The total weight for all of the instances.
     * @return The entropy for the supplied label counts.
     */
    public static double entropy(double[] labelCount,double totalInstanceWeight) {
        MLJ.verify_strictly_greater(totalInstanceWeight, 0, "entropy: totalInstanceWeight is too small");
        if (Globals.DBG) {
            double sum = MLJArray.sum(labelCount);
            MLJ.verify_approx_equal(sum, totalInstanceWeight,
            "entropy(,,): sum and totalWeight don\'t "
            + "match");
        }
        double H = 0;
        for(int y = 0 ; y < labelCount.length ; y++)
            if (labelCount[y] != 0) {
                // We know that totalInstanceWeight > 0 by the check
                //   on verify_strictly_greater above.
                double prob_y = labelCount[y]/  totalInstanceWeight;
                H -= prob_y * log_bin(prob_y);
            }
        return H;
    }
    
    /** Compute the entropy H(Y) for label Y. Giving us an InstanceList forces counters.
     * If you don't give us the total instances, we count (slightly less efficient).
     * Entropy without the sum acts a bit differently by allowing nodes with 0
     * instances and returning entropy -1. The reason is that the caller shouldn't be
     * required to compute the sum just for this.
     *
     * @param instList The supplied instances for whihc entropy will be calculated.
     * @return The entropy value.
     */
    public static double entropy(InstanceList instList) {
        return entropy(instList.counters().label_counts(),instList.total_weight());
    }
    
    
    /** Search a score array to find the best score/index.
     * @param totalKnownWeight Total weight of all Instances for which a value is known.
     * @param scores The scores of the available Splits.
     * @param minSplit The minimum value for a split.
     * @param bestSplitIndex The index of the best split.
     * @return The score of the best split.
     */
    public static double find_best_score(double totalKnownWeight,
    Vector scores, double minSplit,
    IntRef bestSplitIndex) {
        double minimalDistanceFromCenter = totalKnownWeight/  2;
        double bestScore = Globals.UNDEFINED_REAL;
        for(int k = 0 ; k < scores.size(); k++) {
            
            if (totalKnownWeight -((ThresholdInfo)scores.get(k)).weight < minSplit)
                break;
            if (((ThresholdInfo)scores.get(k)).weight < minSplit)
                continue;
            double currentScore =((ThresholdInfo)scores.get(k)).score;
            double currentDistance = Math.abs(totalKnownWeight / 2 -((ThresholdInfo)scores.get(k)).weight);
            
            if (currentScore > bestScore + MLJ.realEpsilon ||(MLJ.approx_equal(bestScore, currentScore)&& currentDistance < minimalDistanceFromCenter)) {
                bestSplitIndex.value =((ThresholdInfo)scores.get(k)).index;
                minimalDistanceFromCenter = currentDistance;
                bestScore = currentScore;
                LogOptions.GLOBLOG(6, "index " +bestSplitIndex+ ", entropy " +bestScore+ '\n');
            }
        }
        return bestScore;
    }
    
    /** Build the splitAndLabelDist and splitDist arrays needed for calculating
     * conditional entropy. 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 over which a split and label distribution is to be
     * built.
     * @return Distributions over each split and label pair.
     */
    public static double[][] build_split_and_label_dist(InstanceList[] currentLevel, int attrNum) {
        return build_split_and_label_dist(currentLevel,attrNum,0);
    }
    
    /** Build the splitAndLabelDist and splitDist arrays needed for calculating
     * conditional entropy. 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 over which a split and label distribution is to be
     * built.
     * @param unaccountedWeight	The weight for instances that are not
     * accounted for in this partition.
     * @return Distributions over each split and label pair.
     */
    public static double[][] build_split_and_label_dist(InstanceList[] currentLevel,
    int attrNum,double unaccountedWeight) {
        MLJ.ASSERT(currentLevel[0] != null, "Entropy::build_split_and_label_dist: currentlevel == null.");
        Schema schema = currentLevel[0].get_schema();
        int numInstLists = currentLevel.length;
        int numLabelValues = schema.num_label_values();
        int numAttrValues = schema.num_attr_values(attrNum);
        MLJ.ASSERT(numInstLists > 0, "Entropy::build_split_and_label_dist: numInstLists <= 0.");
        MLJ.ASSERT(numLabelValues > 0, "Entropy::build_split_and_label_dist: numLabelValues <= 0.");
        MLJ.ASSERT(numAttrValues > 0, "Entropy::build_split_and_label_dist: numAttrValues <= 0.");
        MLJ.ASSERT(unaccountedWeight >= 0, "Entropy::build_split_and_label_dist: unaccountedWeight < 0.");
        double[][] splitAndLabelDist = new double[numLabelValues][numInstLists*(numAttrValues+1)+((MLJ.approx_equal(unaccountedWeight, 0.0))?0:1)];
        int countSplitAndLabelDistCol = 0;
        for(int instListCount = 0 ; instListCount < numInstLists ; instListCount++) {
            MLJ.ASSERT(currentLevel[instListCount] != null, "Entropy::build_split_and_label_dist: currentLevel[instListCount] == null.");
            for(int attrValCount = 0 ;
            attrValCount < numAttrValues +1 ; //add 1 to account for unknown being moved from -1 to 0 -JL
            attrValCount++, countSplitAndLabelDistCol++) {
                for(int labelValCount = 0 ; labelValCount < numLabelValues ;
                labelValCount++) {
                    BagCounters bc = currentLevel[instListCount].counters();
                    splitAndLabelDist[labelValCount][countSplitAndLabelDistCol]=
                    bc.value_counts()[attrNum][labelValCount+1][attrValCount];
                    //labelValCount needs 1 added because the unknown label has
                    //has been moved from -1 to 0. The first nominal label is now
                    //at 1, not 0, in the BagCounters class. -JL
                }
            }
        }
        // Assign the unaccounted to the last split with all counts
        //   for one label (so it looks pure).
        if (unaccountedWeight > 0) {
            MLJ.ASSERT(countSplitAndLabelDistCol == splitAndLabelDist[0][splitAndLabelDist.length], "Entropy::build_split_and_label_dist: countSplitAndLabelDistCol != splitAndLabelDist[0][splitAndLabelDist.length]");
            for(int labelValCount = 0 ; labelValCount < numLabelValues ; labelValCount++)
                splitAndLabelDist[labelValCount][countSplitAndLabelDistCol]=(labelValCount != 0)? 0 : unaccountedWeight;
        }
        return splitAndLabelDist;
    }
    
    /** Returns the minSplit which is used in find_best_threshold(), given
     * lowerBoundMinSplit, upperBoundMinSplit, and minSplitPercent. This
     * function is called by inducers.
     * @return The minSplit which is used in find_best_threshold().
     * @param upperBoundMinSplit Upper bound for the minimum split value.
     * @param totalWeight The total weight of all instances in the list of instances for which a split
     * is requested.
     * @param numTotalCategories Number of possible values an instance may be categorized as.
     * @param lowerBoundMinSplit Lower bound for the minimum split value.
     * @param minSplitPercent The percentage of total weight per category that represents the minimum value
     * for a split.
     */
    public static double min_split(double totalWeight,
    int numTotalCategories, double lowerBoundMinSplit,
    double upperBoundMinSplit, double minSplitPercent) {
        if (numTotalCategories <= 0)
            Error.fatalErr("min_split: divisor (numTotalCategories) is zero or neg");
        if ((Globals.DBG)&&(lowerBoundMinSplit <= 0))
            Error.fatalErr("min_split:  lowerBoundMinSplit ("
            + lowerBoundMinSplit + ") must be at least one");
        double minSplit = minSplitPercent * totalWeight/  numTotalCategories;
        if (minSplit > upperBoundMinSplit)
            minSplit = upperBoundMinSplit;
        if (minSplit <= lowerBoundMinSplit)
            minSplit = lowerBoundMinSplit;
        MLJ.ASSERT(minSplit > 0, "Entropy::build_split_and_label_dist: minSplit <= 0");
        return minSplit;
    }
    
    /** Returns the minSplit which is used in find_best_threshold(), given
     * lowerBoundMinSplit, upperBoundMinSplit, and minSplitPercent. This
     * function is called by inducers.
     * @param instList The list of instances over which a split is requested.
     * @param upperBoundMinSplit Upper bound for the minimum split value.
     * @param lowerBoundMinSplit Lower bound for the minimum split value.
     * @param minSplitPercent The percentage of total weight per category that represents the minimum value
     * for a split.
     * @param ignoreNumCat Indicator that the number of values that an instance may be classified as should
     * be ignored for this split computation.
     * @return The minSplit which is used in find_best_threshold().
     */
    public static double min_split(InstanceList instList,
    double lowerBoundMinSplit, double upperBoundMinSplit,
    double minSplitPercent, boolean ignoreNumCat) {
        if (ignoreNumCat)
            return min_split(instList.total_weight(), 1, lowerBoundMinSplit, upperBoundMinSplit, minSplitPercent);
        else return min_split(instList.total_weight(), instList.num_categories(), lowerBoundMinSplit, upperBoundMinSplit, minSplitPercent);
    }
    
    /** Returns the minSplit which is used in find_best_threshold(), given
     * lowerBoundMinSplit, upperBoundMinSplit, and minSplitPercent. This
     * function is called by inducers.
     * @param instList The list of instances over which a split is requested.
     * @param upperBoundMinSplit Upper bound for the minimum split value.
     * @param lowerBoundMinSplit Lower bound for the minimum split value.
     * @param minSplitPercent The percentage of total weight per category that represents the minimum value
     * for a split.
     * @return The minSplit which is used in find_best_threshold().
     */
    public static double min_split(InstanceList instList,
    double lowerBoundMinSplit, double upperBoundMinSplit,
    double minSplitPercent) {
        return min_split(instList,lowerBoundMinSplit,upperBoundMinSplit,minSplitPercent,false);
    }
    
    
    /** 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 splitAndLabelDist Distributions over each split and label pair.
     * @param splitDist The distribution over splits.
     * @param totalWeight The total weight distributed.
     * @return The conditional entropy.
     */
    public static double cond_entropy(double[][] splitAndLabelDist,
    double[] splitDist, double totalWeight) {//AttrAndOrigin class function
        //   DBG(MLC::verify_strictly_greater(totalWeight, 0,
        //				    "cond_entropy:: totalWeight must be "
        //				    "positive");
        
        double sum = MLJArray.sum(splitDist);
        MLJ.verify_approx_equal(totalWeight, sum,
        "cond_entropy:: totalWeight does not match splitDist");
        sum = Matrix.total_sum(splitAndLabelDist);
        MLJ.verify_approx_equal(totalWeight, sum,
        "cond_entropy:: totalWeight does not match splitAndLabelDist");
        //       DBGSLOW(
        //	       Array<Real> sDist(UNKNOWN_CATEGORY_VAL,
        //				splitAndLabelDist.num_cols());
        //	       splitAndLabelDist.sum_cols(sDist);
        //	       ASSERT(MLJ.approx_equal(sDist, splitDist));
        //	      )
        //       );
        DoubleRef H = new DoubleRef(0);
        for (int x = 0;
        x < splitAndLabelDist[0].length; x++) {
            double num_x = splitDist[x];
            if (MLJ.approx_equal(num_x, 0.0))
                continue;
            for (int y = 0;
            y < splitAndLabelDist.length; y++) {
                double num_xy = splitAndLabelDist[y][x];
                if (MLJ.approx_equal(num_xy, 0.0))
                    continue;
                H.value -= num_xy * log_bin(num_xy/num_x);
            }
        }
        H.value /= totalWeight; // We know this won't be division by zero.
        MLJ.clamp_above(H, 0, "cond_entropy: negative entropy not allowed");

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美在线观看| 精品国产3级a| 久久综合九色综合欧美98 | 亚洲午夜精品一区二区三区他趣| 极品少妇xxxx精品少妇偷拍| 91久久国产最好的精华液| 久久九九久精品国产免费直播| 三级久久三级久久| 色婷婷综合激情| 中文文精品字幕一区二区| 奇米影视一区二区三区| 一本大道久久a久久综合| 精品国内片67194| 欧美日本精品一区二区三区| 99久久婷婷国产综合精品电影| 日韩欧美www| 亚洲成a人片综合在线| av日韩在线网站| 久久久一区二区三区捆绑**| 欧美aⅴ一区二区三区视频| 欧美日产国产精品| 一区二区三区国产| 色8久久人人97超碰香蕉987| 国产精品不卡在线观看| 豆国产96在线|亚洲| 久久久久国产精品厨房| 久久99精品久久久| 精品久久99ma| 韩国中文字幕2020精品| 精品欧美黑人一区二区三区| 日本美女一区二区三区视频| 久久电影国产免费久久电影| 久久在线观看免费| 九一久久久久久| 日韩精品中文字幕在线一区| 日韩av成人高清| 91精品国产色综合久久久蜜香臀| 五月综合激情日本mⅴ| 欧美二区乱c少妇| 免费人成网站在线观看欧美高清| 日韩视频免费观看高清完整版 | 欧美日韩精品一区二区| 亚洲一区二区黄色| 欧美日韩久久久久久| 婷婷综合在线观看| 亚洲精品一区二区三区精华液 | 日本一区二区三区久久久久久久久不| 国产黄色精品视频| 日韩毛片在线免费观看| 欧美在线不卡视频| 久久国产精品99久久人人澡| 久久久精品一品道一区| 一本色道久久综合精品竹菊| 同产精品九九九| 久久蜜桃av一区二区天堂| 99久久精品免费看国产| 性感美女极品91精品| 精品国产自在久精品国产| 顶级嫩模精品视频在线看| 夜夜夜精品看看| 久久久影院官网| 欧美在线看片a免费观看| 久久精品国产免费看久久精品| 久久久一区二区| 在线欧美日韩精品| 国产在线精品视频| 亚洲韩国一区二区三区| 久久久综合精品| 欧美日韩一区二区欧美激情| 国产精品亚洲综合一区在线观看| 一区二区三区在线观看网站| 日韩免费福利电影在线观看| 91麻豆.com| 国产一区二区日韩精品| 亚洲国产婷婷综合在线精品| 欧美经典一区二区三区| 欧美日韩激情一区二区三区| 成人黄色大片在线观看| 久久超碰97人人做人人爱| 亚洲欧美激情小说另类| 欧美xfplay| 欧美高清视频www夜色资源网| 成人av电影在线| 国产在线观看一区二区| 婷婷一区二区三区| 一区二区三区免费看视频| 久久精品网站免费观看| 91精品黄色片免费大全| 一本久久精品一区二区| 丁香五精品蜜臀久久久久99网站 | 91亚洲精品久久久蜜桃网站 | 国产一区二区三区精品欧美日韩一区二区三区 | 国产在线播放一区二区三区| 丝袜亚洲精品中文字幕一区| 亚洲美女免费在线| 欧美激情综合五月色丁香| 精品国产亚洲在线| 这里是久久伊人| 欧美日韩中文字幕一区| 91免费视频网址| 99久久99久久精品国产片果冻| 国产精品1024久久| 国产传媒欧美日韩成人| 国产一区三区三区| 国产自产高清不卡| 国内成+人亚洲+欧美+综合在线 | 日韩久久久精品| 日韩限制级电影在线观看| 欧美日韩精品一区二区天天拍小说| 色av一区二区| 一本一本大道香蕉久在线精品| 成人97人人超碰人人99| 成人av影院在线| 99在线精品观看| 色综合久久综合中文综合网| 91麻豆视频网站| 欧美视频在线播放| 在线综合视频播放| 精品国内片67194| 国产色产综合色产在线视频| 中文字幕欧美区| 亚洲欧洲韩国日本视频| 亚洲柠檬福利资源导航| 亚洲一区二区在线视频| 亚洲a一区二区| 久久99久久99| 丁香婷婷综合激情五月色| 成人国产电影网| 91看片淫黄大片一级在线观看| 欧美性受xxxx| 日韩三级高清在线| 国产婷婷精品av在线| 亚洲欧洲美洲综合色网| 亚洲bt欧美bt精品| 激情综合色丁香一区二区| 国产不卡视频一区二区三区| 色综合中文字幕国产 | 在线观看欧美黄色| 91精品国产综合久久久久久| 久久综合九色欧美综合狠狠| 国产精品免费av| 亚洲国产精品一区二区www在线| 免费看欧美美女黄的网站| 国产精品主播直播| 欧美午夜一区二区| 精品免费视频一区二区| 亚洲精品国久久99热| 久久99这里只有精品| 色国产精品一区在线观看| 欧美日韩不卡视频| 欧美经典一区二区| 日本午夜精品一区二区三区电影 | 欧美日本在线一区| 国产欧美视频一区二区三区| 一区二区视频免费在线观看| 久久aⅴ国产欧美74aaa| 日本丶国产丶欧美色综合| 日韩亚洲欧美高清| 亚洲男人天堂av网| 国产成人午夜精品5599| 欧美精品久久99久久在免费线| 国产欧美精品一区二区色综合朱莉| 亚洲国产aⅴ天堂久久| 国产91精品入口| 日韩一区二区高清| 亚洲成人午夜影院| 成人高清av在线| 精品国产污网站| 日本伊人午夜精品| 欧美影院一区二区三区| 国产精品成人免费在线| 精品一区二区在线观看| 欧美日韩国产综合久久| 亚洲私人影院在线观看| 国产精品1024| 精品国产乱码久久久久久夜甘婷婷| 亚洲一区在线视频观看| www.一区二区| 国产农村妇女精品| 久久91精品久久久久久秒播| 欧美日韩午夜在线| 亚洲激情av在线| 91麻豆免费视频| 国产精品久久久久久妇女6080| 国产福利一区二区| 国产网站一区二区| 国产一区二区在线电影| 精品国产3级a| 精品亚洲国产成人av制服丝袜| 91精品国产91久久综合桃花| 亚洲主播在线观看| 精品视频在线视频| 亚洲第一二三四区| 欧美日韩免费一区二区三区| 夜夜嗨av一区二区三区网页| 欧美视频一区二区| 亚洲成人av资源| 欧美一级理论片| 国产一区 二区| 国产精品免费久久久久|