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

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

?? entropy.java

?? java數據挖掘算法
?? 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一区二区三区免费野_久草精品视频
欧美精品一区二区久久久| 亚洲一区二区三区在线播放| 久久精品视频一区二区| 国产欧美精品一区aⅴ影院| 亚洲综合激情另类小说区| 国产美女视频91| 欧美一级精品大片| 亚洲一区二区三区四区在线 | 国产呦萝稀缺另类资源| 欧美视频中文字幕| 国产精品国产三级国产aⅴ入口| 婷婷丁香久久五月婷婷| 色综合av在线| 自拍偷拍国产亚洲| 国产91精品欧美| 欧美mv日韩mv| 一区二区三区在线观看网站| 白白色 亚洲乱淫| 国产欧美一区二区在线| 国产在线精品视频| 日韩久久免费av| 免费一级片91| 日韩一区二区三区在线| 日韩在线a电影| 欧美日韩一区二区三区不卡 | 欧美日韩三级在线| 亚洲精品中文在线| 欧洲精品一区二区三区在线观看| 日本一区二区三区dvd视频在线| 日本欧美韩国一区三区| 欧美人妇做爰xxxⅹ性高电影| 亚洲精品一二三区| 9人人澡人人爽人人精品| 国产精品乱码一区二区三区软件| 国产美女久久久久| 国产精品私人影院| 成人免费黄色大片| 国产精品国产a| 成人午夜视频在线观看| 中文字幕永久在线不卡| 日本道在线观看一区二区| 亚洲久本草在线中文字幕| 在线亚洲一区观看| 午夜视频在线观看一区二区三区 | 国产福利91精品一区| 久久久av毛片精品| 成人国产视频在线观看| 亚洲免费av观看| 欧美日韩久久一区| 蜜臀精品久久久久久蜜臀| 精品国产一区二区三区久久影院 | 日本午夜一本久久久综合| 日韩欧美中文字幕制服| 国产一区二区精品久久91| 国产女同互慰高潮91漫画| 99国产欧美久久久精品| 亚洲国产成人va在线观看天堂| 欧美欧美欧美欧美| 国产一区二区三区四| 中文字幕一区二区三区乱码在线| 91久久精品日日躁夜夜躁欧美| 视频一区国产视频| 久久精品亚洲精品国产欧美| av电影在线不卡| 日韩成人dvd| 国产色产综合色产在线视频| 色婷婷激情一区二区三区| 日本在线播放一区二区三区| 欧美激情一区二区三区全黄| 欧美性色综合网| 蜜桃视频第一区免费观看| 久久久久国产精品厨房| av电影天堂一区二区在线| 三级精品在线观看| 成人欧美一区二区三区1314| 欧美一级生活片| 91色在线porny| 韩国成人福利片在线播放| 亚洲人成伊人成综合网小说| 日韩美女视频在线| 欧美在线一区二区| 粉嫩蜜臀av国产精品网站| 午夜精品福利在线| 欧美韩国日本综合| 日韩小视频在线观看专区| 色综合久久六月婷婷中文字幕| 免费看黄色91| 亚洲一区二区三区四区在线 | 成人av电影免费在线播放| 日本成人在线看| 一区二区三区日韩精品视频| 久久久精品综合| 日韩欧美一区二区免费| 欧美专区日韩专区| 99久久精品国产一区二区三区 | 久久亚洲一区二区三区四区| 欧美性高清videossexo| 99在线精品一区二区三区| 国产一区二区三区久久久| 日本成人中文字幕| 亚洲国产裸拍裸体视频在线观看乱了| 欧美韩国日本不卡| 久久这里只有精品6| 日韩一级片在线观看| 777色狠狠一区二区三区| 欧美午夜影院一区| 成人美女在线观看| 国产一区二区按摩在线观看| 五月天精品一区二区三区| 一区二区三区久久久| 亚洲男人的天堂av| 亚洲欧美偷拍另类a∨色屁股| 日本一区二区三区四区| 国产欧美精品一区| 亚洲国产精华液网站w| 中文字幕av不卡| 中文字幕在线不卡一区| 成人欧美一区二区三区| 亚洲婷婷国产精品电影人久久| 国产精品伦理一区二区| 国产精品精品国产色婷婷| 国产精品久久一级| 亚洲欧美一区二区三区国产精品 | 国产精品超碰97尤物18| 国产精品色在线观看| 国产精品福利在线播放| 国产精品美女久久久久久久| 亚洲色图欧美在线| 亚洲一区日韩精品中文字幕| 亚洲国产精品一区二区www| 日韩黄色片在线观看| 看片网站欧美日韩| 国产成人精品亚洲午夜麻豆| 99久久精品费精品国产一区二区| 91亚洲男人天堂| 欧美浪妇xxxx高跟鞋交| 精品日韩99亚洲| 国产精品动漫网站| 亚洲va韩国va欧美va| 狠狠色伊人亚洲综合成人| 国产盗摄女厕一区二区三区| 91美女在线观看| 69堂成人精品免费视频| 久久网这里都是精品| 国产精品视频观看| 日韩在线播放一区二区| 国产乱码字幕精品高清av| 91偷拍与自偷拍精品| 7777女厕盗摄久久久| 国产亚洲午夜高清国产拍精品| 亚洲天天做日日做天天谢日日欢 | 9191久久久久久久久久久| 色天使久久综合网天天| 欧美日韩高清一区二区三区| 国产.欧美.日韩| 欧美人成免费网站| 国产日韩成人精品| 午夜视频在线观看一区二区三区| 九色综合狠狠综合久久| www.色综合.com| 欧美不卡一区二区三区四区| 中文字幕综合网| 久久精品国产亚洲aⅴ| 色悠久久久久综合欧美99| 精品国产91久久久久久久妲己 | 在线成人免费视频| 国产欧美日韩精品一区| 日本免费新一区视频| 91麻豆精品在线观看| 久久久久久久久蜜桃| 午夜av区久久| 一本色道亚洲精品aⅴ| 久久久久久久久久久99999| 日韩经典一区二区| 色琪琪一区二区三区亚洲区| 国产三级一区二区| 久久精品99久久久| 欧美精品日韩一本| 亚洲国产欧美一区二区三区丁香婷| 成人激情综合网站| 精品国产乱码久久久久久久久| 亚洲成人av电影| 欧美做爰猛烈大尺度电影无法无天| 国产三级精品在线| 国产又黄又大久久| 亚洲精品一区二区三区福利| 免费视频一区二区| 欧美精品久久久久久久久老牛影院| 亚洲人成亚洲人成在线观看图片| 国产九九视频一区二区三区| 日韩免费高清视频| 毛片一区二区三区| 日韩午夜av电影| 男人的j进女人的j一区| 欧美日韩久久一区| 天堂蜜桃91精品| 在线综合+亚洲+欧美中文字幕| 亚洲一区二区三区不卡国产欧美| 色久优优欧美色久优优| 亚洲免费观看高清在线观看|