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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? entropy.java

?? 本程序是用java語(yǔ)言編寫(xiě)的數(shù)據(jù)挖掘分類(lèi)算法中的決策樹(shù)分類(lèi)方法c4.5程序代碼
?? JAVA
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
package shared;
import java.lang.*;
import java.util.*;

/** This class handles all of the Entropy based calculations. All logs
 * are base 2 (other bases just scale the entropy). The reason for using
 * log_bin is simply that the examples in Quinlan's C4.5 book use it, and
 * those examples were used for testing.  It's also a measure of the
 * number of "bits" in information theory, so it's appealing in that sense
 * too. The computation is based on:                                           <BR>
 * 1. "Boolean Feature Discovery in Empirical Learning" / Pagallo and
 * Haussler.                                                                   <BR>
 * 2. "A First Course in Probability, 2nd Edition" / Ross, pages 354-359.
 *                                                                            <BR>
 * 3. "C4.5: Programs for Machine Learning" / Ross Quinlan, pages 18-24.
 *                                                                            <BR>
 * @author James Louis 5/21/2001	Java implementations.
 * @author Cliff Brunk 5/25/96 Added weight to find_best_threshold and
 * get_split_score.
 * @author Eric Eros 12/05/96 Revised find_best_threshold to use
 * SplitAttr, and to use RealAndLabelColumn and SplitAttr.
 * @author Chia-Hsin Li Revised find_best_threshold to allow multiple
 * InstanceLists.
 * @author Brian, Ronny Kohavi 9/04/93 Initial revision
 */
public class Entropy {
    
    /** Constant for binary log calculations.
     */
    static public double M_LOG2E = 1.4426950408889634074;
    
    /** Automatically determine a good lower bound for minSplit, based on the
     * total weight of an instance list at the start of training.
     * @param totalWeight	The total weight of instances in this
     * InstanceList partition.
     * @return A lower bound for minSplit.
     */
    public static double auto_lbound_min_split(double totalWeight) {
        double k = 1.851;
        double m = 8.447;
        if (totalWeight < 1)
            return 1;
        return Math.max(1.0, k*log_bin(totalWeight)-m);
    }
    
    /** Returns the log base two of the supplied number.
     * @param num	The number for which a log is requested.
     * @return The log base two of the supplied number.
     */
    public static double log_bin(double num) {
        //      return Math.log(num)/ Math.log(2);
        return Math.log(num) * M_LOG2E;
    }
    
    /** Compute the best threshold for RealAndLabelColumn(s). Initially, all
     * instances are at the right hand side of splitDist and
     * splitAndLabelDist. To find the best threshold, we shift the instances
     * from right to left and calculate their conditional entropy. Then we
     * pick up the one with minimum conditional entropy and return
     * bestThreshold and minCondEntropy as results. When two entropies are
     * equal, we prefer the one that splits instances equally into two bins
     * in the hope of making the tree shallower. Tests show minor effect but
     * it does help pima for different leaf counts.
     * @param realAndLabelColumn The column of real values and their associated labels
     * @param minSplit The split value for which conditional entropy is minimal.
     * @param split The scores for all available splits.
     * @param bestThreshold The real value that is the best threshold over the supplied real values.
     * @param bestSplitIndex Index of the best split in the supplied RealAndLabelColumn.
     * @param numDistinctValues The number of non-equal values.
     * @param smoothInst The index of the instance to be smoothed toward.
     * @param smoothFactor The amount of normalization done towards the specified instance index.
     */
    public static void find_best_threshold(RealAndLabelColumn realAndLabelColumn,
    double minSplit, SplitScore split,
    DoubleRef bestThreshold, IntRef bestSplitIndex,
    IntRef numDistinctValues, int smoothInst,
    double smoothFactor) {
        if (minSplit < 0)
            Error.fatalErr("find_best_threshold:  minSplit(" +minSplit+ ") must be at least 0");
        bestThreshold.value = Globals.UNDEFINED_REAL;
        bestSplitIndex.value = 0;
        numDistinctValues.value = 0;
        double totalKnownWeight = realAndLabelColumn.known_weight();
        if (realAndLabelColumn.known_weight()<(2 * minSplit)) {
            split.reset();
            return;
        }
        Vector scores = new Vector();
        double[][] sAndLDist = get_score_array(realAndLabelColumn,
        split, minSplit,
        scores, numDistinctValues,
        smoothInst, smoothFactor);
        if (sAndLDist == null)
            return;
        double bestScore = find_best_score(totalKnownWeight,
        scores, minSplit, bestSplitIndex);
        if (bestScore > Globals.UNDEFINED_REAL) {
            bestThreshold.value =
            ((double)(realAndLabelColumn.index(bestSplitIndex.value - 1).value)+
            (double)(realAndLabelColumn.index(bestSplitIndex.value).value))/ 2;
            for(int k = 1 ; k <= bestSplitIndex.value ; k++) {
                AttrLabelPair alp = realAndLabelColumn.index(k - 1);
                int lab = alp.label;
                double weight = alp.weight;
                sAndLDist[lab][Globals.RIGHT_NODE] -= weight;
                sAndLDist[lab][Globals.LEFT_NODE] += weight;
                if (MLJ.approx_equal(sAndLDist[lab][Globals.RIGHT_NODE],0))
                    sAndLDist[lab][Globals.RIGHT_NODE]= 0;
            }
            sAndLDist = split.set_split_and_label_dist(sAndLDist);
        }
        else {
            split.reset();
            sAndLDist = null;
        }
        MLJ.ASSERT(sAndLDist == null, "Entropy::find_best_threshold: sAndLDist == null");
    }
    
    /** Calculates the distribution array for the given sorted
     * RealAndLabelColumn. This function then progresses through the input array,
     * shifting counts from the right to the left (in the distributions).
     * When the Real values in the input array change, the potential score of
     * a split at that value is calculated, and stored in the output array,
     * outScores. At the end, outScores contains the discrete thresholds, the
     * scores associated with a split at each of these thresholds, and the
     * indices into the original array.
     * @param realAndLabelColumn The supplied column of real values and their associated label values.
     * @param split The scores for all available splits.
     * @param minSplit The split value for which conditional entropy is minimal.
     * @param outScores The scores after smoothing.
     * @param numDistinctValues The number of non-equal values.
     * @param smoothInst The index of the instance to be smoothed towards.
     * @param smoothFactor The amount of normalization done towards the specified instance index.
     * @return The split and label distribution.
     */
    public static double[][] get_score_array(RealAndLabelColumn realAndLabelColumn,
    SplitScore split, double minSplit,
    Vector outScores,
    IntRef numDistinctValues, int smoothInst,
    double smoothFactor) {
        int numLabels = realAndLabelColumn.label_count();
        double[][] splitAndLabelDist = new double[numLabels+1][3];
        Matrix.initialize(0,splitAndLabelDist);
        double[] splitDist = new double[3];
        realAndLabelColumn.init_dist_counts(splitAndLabelDist, splitDist);
        double[] labelDist = new double[splitAndLabelDist.length];
        Matrix.sum_rows(labelDist,splitAndLabelDist);
        int numUsedLabels = 0;
        for(int labelNum = 0 ;
        labelNum < splitAndLabelDist.length ;
        labelNum++)
            if (labelDist[labelNum] > 0)
                ++numUsedLabels;
        if (numUsedLabels < 2) {
            split.reset();
            return null;
        }
        double theEntropy = entropy(labelDist);
        
        double[][] sAndLDist = new double[splitAndLabelDist.length][splitAndLabelDist[0].length];
        for(int i = 0 ; i < splitAndLabelDist.length ; i++)
            for(int j = 0 ; j < splitAndLabelDist[0].length ; j++)
                sAndLDist[i][j] = splitAndLabelDist[i][j];
        numDistinctValues.value = 0;
        fill_scores(realAndLabelColumn, split, minSplit, theEntropy,
        outScores, numDistinctValues, splitAndLabelDist, splitDist);
        if (sAndLDist != null && smoothInst != 0)
            smooth_scores(outScores, smoothInst, smoothFactor);
        return sAndLDist;
    }
    
    /** Normalizes the scores towards the instance at the supplied index.
     * @param scores The set of scores to be smoothed.
     * @param smoothInst The index of the instance to be smoothed towards.
     * @param smoothFactor The amount of normalization done towards the specified instance index.
     */
    public static void smooth_scores(Vector scores, int smoothInst, double smoothFactor) {
        double[] oldScores = new double[smoothInst+1];
        MLJArray.init_values(-1,oldScores);
        int numThresholds = scores.size();
        
        for(int i = 0 ; i < numThresholds ; i++) {
            double summedScores =((ThresholdInfo)scores.get(i)).score;
            double summedFactor = 1;
            double currFactor = smoothFactor;
            for(int left = 1 ; i - left >= 0 && left <= smoothInst ; left++) {
                summedScores +=(currFactor *((ThresholdInfo)scores.get(i - left)).score);
                summedFactor += currFactor;
                currFactor *= smoothFactor;
            }
            currFactor = smoothFactor;
            for(int right = 1 ; i + right < numThresholds && right <= smoothInst ; right++) {
                summedScores +=(currFactor *((ThresholdInfo)scores.get(i + right)).score);
                summedFactor += currFactor;
                currFactor *= smoothFactor;
            }
            if (i > smoothInst) {
                ((ThresholdInfo)scores.get(i - smoothInst - 1)).score = oldScores[smoothInst];
            }
            for(int j = smoothInst - 1 ; j >= 0 ; j--) {
                oldScores[j+1] = oldScores[j];
            }
            if (MLJ.approx_equal(summedFactor, 0.0))
                Error.fatalErr("smooth_scores: divisor (summedFactor) too close to zero");
            oldScores[0] = summedScores/  summedFactor;
        }
        for(int j = 0 ; j < smoothInst+1 ; j++) {
            if (numThresholds - smoothInst - 1 + j >= 0)
                ((ThresholdInfo)scores.get(numThresholds - smoothInst - 1 + j)).score = oldScores[smoothInst - j];
        }
    }
    
    /** Fills the Vector of scores with the scores for all the thresholds.
     * The number of distinct values is only true for the range of numbers if
     * the relevant range that does not include minSplit on the right and left.
     * @param realAndLabelColumn The column of real values and their associated labels over which thresholds are
     * created.
     * @param split The SplitScore used for scoring this threshold split.
     * @param minSplit The minimum value for splits.
     * @param theEntropy The Entropy value
     * @param outScores The Vector of scores to be filled.
     * @param numDistinctValues The number of distinct real values for this attribute.
     * @param splitAndLabelDist Distributions over each split and label pair.
     * @param splitDist The distribution over splits.
     */
    public static void fill_scores(RealAndLabelColumn realAndLabelColumn,
    SplitScore split, double minSplit, double theEntropy,
    Vector outScores, IntRef numDistinctValues, double[][] splitAndLabelDist,
    double[] splitDist) {
        double totalWeight = realAndLabelColumn.total_weight();
        int numKnownInstances = realAndLabelColumn.known_count();
        float lastSeen = realAndLabelColumn.index(0).value;
        int threshIndex = 0;
        // We start at 1 because we're comparing a split just before this
        //   element
        for(int k = 1 ; k < numKnownInstances ; k++) {
            AttrLabelPair alp = realAndLabelColumn.index(k - 1);
            float value = alp.value;
            int lab = alp.label;
            double weight = alp.weight;
            float nextValue = realAndLabelColumn.index(k).value;
            splitDist[Globals.RIGHT_NODE] -= weight;
            splitDist[Globals.LEFT_NODE] += weight;
            if (MLJ.approx_equal((float)splitDist[Globals.RIGHT_NODE], 0.0))
                splitDist[Globals.RIGHT_NODE] = 0;
            splitAndLabelDist[lab][Globals.RIGHT_NODE] -= weight;
            splitAndLabelDist[lab][Globals.LEFT_NODE] += weight;
            if (MLJ.approx_equal((float)splitAndLabelDist[lab][Globals.RIGHT_NODE], 0.0))
                splitAndLabelDist[lab][Globals.RIGHT_NODE] = 0;
            double deltaAttr =(double)nextValue -(double)(lastSeen);
            MLJ.ASSERT(deltaAttr >= 0, "Entropy::fill_scores: deltaAttr >= 0 : deltaAttr == " +deltaAttr);
            if (deltaAttr < 2 * MLJ.storedRealEpsilon)
                continue;
            lastSeen = nextValue;
            if (nextValue - value < MLJ.storedRealEpsilon)
                continue;
            if (splitDist[Globals.RIGHT_NODE] >= minSplit && splitDist[Globals.LEFT_NODE] >= minSplit)
                numDistinctValues.value = numDistinctValues.value + 1;
            
            ThresholdInfo outScore = new ThresholdInfo();
            outScores.add(threshIndex++,outScore);
            outScore.index = k;
            outScore.weight = splitDist[Globals.LEFT_NODE];
            outScore.score = split.score(splitAndLabelDist, splitDist, null, theEntropy, totalWeight);
        }
    }
    
    /** 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.
     *

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一区视频| 精品福利在线导航| 国产一本一道久久香蕉| 亚洲黄色av一区| 精品国产91久久久久久久妲己| 91在线观看视频| 久久99深爱久久99精品| 亚洲一区二区三区四区的| 亚洲国产精品精华液2区45| 欧美日韩dvd在线观看| av中文一区二区三区| 韩国毛片一区二区三区| 午夜av区久久| 亚洲一区二区成人在线观看| 欧美韩日一区二区三区四区| 精品福利av导航| 91精品国产高清一区二区三区| 一本大道av一区二区在线播放| 国产精品亚洲人在线观看| 日本vs亚洲vs韩国一区三区二区| 亚洲女人小视频在线观看| 中文字幕第一区| 欧美激情一区二区在线| 精品福利视频一区二区三区| 91精品国产色综合久久 | 成人av免费观看| 韩国精品主播一区二区在线观看| 午夜精品久久久久久久| 亚洲精品综合在线| 亚洲欧美日韩成人高清在线一区| 国产欧美一区二区精品秋霞影院| 精品免费日韩av| 精品理论电影在线观看| 日韩三级免费观看| 91精品视频网| 欧美一区二区视频网站| 欧美精品乱人伦久久久久久| 欧美婷婷六月丁香综合色| 色乱码一区二区三区88| 欧美中文字幕久久| 欧美日韩一区二区三区四区| 在线精品亚洲一区二区不卡| 91国在线观看| 欧美色综合影院| 欧美精品九九99久久| 在线成人av影院| 精品久久人人做人人爽| 日韩精品自拍偷拍| 久久久美女毛片| 欧美激情在线一区二区三区| 中文一区二区完整视频在线观看| 欧美激情在线免费观看| 亚洲人成精品久久久久久| 亚洲精品视频在线看| 亚洲在线观看免费视频| 丝瓜av网站精品一区二区| 蜜臀av一区二区| 丁香婷婷综合色啪| 91偷拍与自偷拍精品| 欧美怡红院视频| 日韩精品中午字幕| 欧美极品aⅴ影院| 亚洲九九爱视频| 日韩国产一区二| 国产酒店精品激情| 成人黄色小视频在线观看| 免费一级片91| 亚洲成人av在线电影| 日本久久电影网| 51精品视频一区二区三区| 中文字幕成人av| 麻豆高清免费国产一区| 欧美性受极品xxxx喷水| 国产精品久久久久aaaa樱花| 奇米综合一区二区三区精品视频| 在线观看一区二区精品视频| 日本一区二区综合亚洲| 久久精品国产网站| 欧美日韩日日骚| 亚洲精品老司机| va亚洲va日韩不卡在线观看| 久久一区二区视频| 久久国产综合精品| 欧美高清www午色夜在线视频| 亚洲精品国产视频| 91在线高清观看| 国产精品伦理一区二区| 国产精品一区二区久久不卡| 欧美成人video| 日韩国产欧美在线观看| 欧美久久久久久久久| 一区二区三区高清| 在线一区二区三区四区| 亚洲精选免费视频| 色88888久久久久久影院野外| 国产精品国产三级国产专播品爱网| 国内久久精品视频| 久久久久久久久免费| 激情综合网av| 亚洲精品一区二区三区影院 | 久久久久久久久久美女| 精品一区二区在线看| 精品免费一区二区三区| 美国十次了思思久久精品导航| 欧美精品v国产精品v日韩精品| 亚洲午夜影视影院在线观看| 在线视频你懂得一区二区三区| 一区二区三区日韩精品| 在线看不卡av| 日韩激情视频网站| 日韩免费看的电影| 国内成人精品2018免费看| 久久男人中文字幕资源站| 国产成人免费xxxxxxxx| 国产精品国产a| 在线观看免费一区| 日韩精品五月天| 精品久久久久久最新网址| 国产一区啦啦啦在线观看| 国产欧美一区二区三区在线看蜜臀 | 国产精品成人免费在线| 91女神在线视频| 香蕉成人啪国产精品视频综合网| 欧美日韩国产电影| 精品一区二区三区影院在线午夜| 2021国产精品久久精品| 成人久久18免费网站麻豆| 亚洲视频图片小说| 337p亚洲精品色噜噜噜| 激情久久五月天| 中文字幕亚洲精品在线观看| 欧洲一区二区三区免费视频| 日韩不卡一区二区| 国产性色一区二区| 一本久久综合亚洲鲁鲁五月天| 亚洲h在线观看| 久久综合色天天久久综合图片| 高清不卡一区二区在线| 亚洲国产日韩在线一区模特| 日韩一级黄色片| 成人91在线观看| 日本 国产 欧美色综合| 欧美国产日产图区| 欧美日韩一区精品| 国产精品99久久久久| 亚洲另类中文字| 精品嫩草影院久久| 日本精品一区二区三区高清| 乱一区二区av| 一区二区三区欧美在线观看| 欧美成人vr18sexvr| 色视频欧美一区二区三区| 麻豆国产精品777777在线| 亚洲视频 欧洲视频| 日韩精品一区二区三区老鸭窝 | 欧美在线免费观看亚洲| 国产最新精品精品你懂的| 亚洲青青青在线视频| 日韩亚洲欧美一区二区三区| 99re这里都是精品| 久久精品国产成人一区二区三区 | 欧美一区二区在线观看| 成人黄色电影在线| 秋霞午夜av一区二区三区| 综合在线观看色| 久久噜噜亚洲综合| 欧美日韩免费观看一区三区| 成人永久免费视频| 麻豆成人91精品二区三区| 一区二区三区不卡视频| 国产欧美一区二区精品秋霞影院| 337p亚洲精品色噜噜噜| 91亚洲国产成人精品一区二三| 国产又粗又猛又爽又黄91精品| 午夜亚洲国产au精品一区二区| 国产精品乱子久久久久| 精品三级在线观看| 欧美一区二区三区在| 欧美午夜精品一区| 色一区在线观看| 成人污污视频在线观看| 精品一区二区三区影院在线午夜| 午夜久久久久久久久| 亚洲女性喷水在线观看一区| 国产女主播视频一区二区| 精品少妇一区二区三区| 欧美一区二区成人| 欧美日韩高清影院| 在线看国产日韩| 91在线精品秘密一区二区| 福利一区二区在线| 国产黄色精品网站| 精品久久久久久无| 这里是久久伊人| 欧美精品18+| 欧美日韩一区二区三区在线| 欧美在线高清视频| 欧美影视一区在线| 在线免费观看日韩欧美| 91久久人澡人人添人人爽欧美 |