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

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

?? entropy.java

?? c4.5 ID3 分類決策數 公用java包 share
?? 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一区二区三区免费野_久草精品视频
午夜一区二区三区视频| 美日韩黄色大片| 一区二区三区加勒比av| 91 com成人网| 91最新地址在线播放| 国产剧情av麻豆香蕉精品| 亚洲成人在线网站| 成人欧美一区二区三区1314| 日韩一区二区三区免费观看| 一本久久综合亚洲鲁鲁五月天| 狠狠色丁香婷综合久久| 日产精品久久久久久久性色| 亚洲男人电影天堂| 中文一区二区完整视频在线观看| 日韩精品一区国产麻豆| 欧美视频在线播放| av在线不卡免费看| 高清av一区二区| 国产一区二区在线免费观看| 天天综合网 天天综合色| 亚洲综合色自拍一区| 亚洲视频在线一区| 国产精品传媒入口麻豆| 国产视频一区不卡| 欧美精品一区二区三区蜜桃| 日韩欧美在线综合网| 91精品国产一区二区三区蜜臀| 91黄视频在线| 色综合视频在线观看| 成人av一区二区三区| 国产成人av一区二区| 激情综合网天天干| 激情综合一区二区三区| 久久91精品国产91久久小草| 日韩av不卡在线观看| 日韩一区精品视频| 热久久国产精品| 美国十次综合导航| 精品亚洲porn| 国产精品一区二区久久不卡| 国产一区三区三区| 国产美女一区二区三区| 国产毛片精品视频| 国产成人精品亚洲午夜麻豆| 成人性生交大片| 成人黄色免费短视频| 91网址在线看| 精品视频一区二区三区免费| 欧美日韩国产另类不卡| 日韩欧美国产1| 久久日韩精品一区二区五区| 国产视频一区在线观看| 综合久久久久久| 亚洲一区二区三区免费视频| 爽爽淫人综合网网站| 狠狠色丁香婷综合久久| 不卡一区中文字幕| 欧美日韩一本到| 精品国产一区二区三区忘忧草| 国产午夜精品在线观看| 国产精品成人免费精品自在线观看| 亚洲视频免费在线观看| 香蕉成人啪国产精品视频综合网| 另类欧美日韩国产在线| 成人综合激情网| 欧美影院一区二区| 欧美电视剧免费观看| 国产精品视频线看| 亚洲午夜电影在线| 国产做a爰片久久毛片| 91美女视频网站| 日韩一区二区三区视频在线| 中文字幕av一区二区三区免费看| 亚洲激情五月婷婷| 精品亚洲国产成人av制服丝袜 | 中文字幕第一区第二区| 亚洲一区精品在线| 老司机午夜精品99久久| av在线一区二区| 欧美一区二区女人| 亚洲色图欧美激情| 精一区二区三区| 色婷婷综合久久久| 精品美女一区二区| 亚洲自拍偷拍网站| 国产v综合v亚洲欧| 日韩一级黄色大片| 亚洲欧洲精品一区二区三区不卡| 日韩国产在线观看一区| voyeur盗摄精品| 精品国一区二区三区| 一区二区成人在线| 国产高清亚洲一区| 91精品国产欧美一区二区18| 中文字幕亚洲欧美在线不卡| 琪琪一区二区三区| 欧美性xxxxxxxx| 国产精品狼人久久影院观看方式| 日韩电影网1区2区| 一本久久a久久精品亚洲| 久久久www免费人成精品| 午夜视频在线观看一区二区三区| 成人av电影在线| 精品91自产拍在线观看一区| 亚洲国产日日夜夜| 99久久婷婷国产综合精品电影| 精品国产乱码久久久久久牛牛 | 亚洲综合偷拍欧美一区色| 国产精品一区二区视频| 日韩一本二本av| 亚洲成av人综合在线观看| 99久久99久久精品免费看蜜桃 | 亚洲欧洲一区二区三区| 国产一区二区视频在线| 欧美精品一二三四| 亚洲国产一区二区三区| 色美美综合视频| 亚洲视频免费观看| 99久久久免费精品国产一区二区| 久久亚洲影视婷婷| 久久99国产精品久久99果冻传媒| 欧美日韩另类一区| 亚洲午夜在线电影| 在线观看日韩毛片| 一区二区三区在线免费观看| 不卡视频在线观看| 国产精品剧情在线亚洲| 国产99久久久久| 国产精品久久综合| 不卡av在线网| 中文字幕精品一区二区精品绿巨人| 国内精品写真在线观看| 26uuu国产电影一区二区| 久久超碰97中文字幕| 日韩精品中午字幕| 久久精品噜噜噜成人av农村| 欧美成人精品福利| 精品系列免费在线观看| 久久精品一区二区三区不卡牛牛| 国产一区二区三区久久久| 欧美电视剧免费观看| 国产美女视频一区| 国产精品嫩草影院com| 成人av综合在线| 亚洲视频一区在线| 欧美色图激情小说| 奇米色777欧美一区二区| 精品国产一区二区三区久久影院| 国产一区在线看| 亚洲欧美在线视频观看| 在线观看亚洲一区| 日本不卡在线视频| 久久久久88色偷偷免费 | 日韩视频国产视频| 国产在线精品一区二区不卡了| 国产亚洲自拍一区| 97aⅴ精品视频一二三区| 亚洲成人tv网| 久久在线观看免费| av中文字幕在线不卡| 亚洲成人综合在线| 欧美精品一区二区在线播放| 成人小视频在线观看| 亚洲午夜电影在线观看| 337p粉嫩大胆色噜噜噜噜亚洲| 国产99一区视频免费| 亚洲自拍偷拍综合| 26uuu成人网一区二区三区| 93久久精品日日躁夜夜躁欧美| 婷婷丁香久久五月婷婷| 欧美激情艳妇裸体舞| 欧美日韩在线播放三区四区| 精品综合久久久久久8888| 亚洲天堂久久久久久久| 欧美丰满美乳xxx高潮www| 国产精品系列在线播放| 一区二区成人在线观看| 久久久久国产精品厨房| 欧美zozo另类异族| caoporn国产一区二区| 日韩精品成人一区二区在线| 中文字幕免费在线观看视频一区| 欧美色图第一页| 高清不卡在线观看| 麻豆精品在线观看| 亚洲精选在线视频| 国产亚洲欧美日韩俺去了| 欧美自拍偷拍一区| 成人免费视频视频在线观看免费 | 欧美综合亚洲图片综合区| 国产自产2019最新不卡| 亚洲国产精品人人做人人爽| 亚洲国产精品激情在线观看| 日韩一区二区电影网| 91国偷自产一区二区开放时间| 韩国精品一区二区| 日韩一区精品视频| 玉足女爽爽91| 中文字幕的久久| 久久伊人中文字幕|