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

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

?? nodecategorizer.java

?? ID3 分類決策數java代碼 需要ID3java代碼公用包
?? JAVA
字號:
package id3;
import java.lang.*;
import java.util.*;
import shared.*;
import shared.Error;
/** An abstract base class categorizer for categorizers that may sit in nodes of
 * decision trees, graphs, etc. Categorizers of this sort generally categorize by
 * making a decision about the instance, and then asking one or more other
 * categorizers in the graph to categorize. The recursion ends when a
 * NodeCategorizer can decide on the category (or distribution, in the case of
 * scoring) without consulting other categorizers.
 *
 * @author James Louis 4/16/2002 Java implementation.
 * @author Clay Kunz 08/08/97 Initial revision (.h,.c)
 */
abstract public class NodeCategorizer extends Categorizer{
    
    //	public NodeCategorizer(){}
    
    // Member data
    private NodeLoss lossInfo;
    private Node nodePtr;
    private CGraph cGraph;
    private boolean smoothDistribution;
    private double smoothFactor;
    //   private DBG_DECLARE(boolean checkGraph;)
    
    
    /** Prints an empty string to System.out.
     */
    public void stop(){
        System.out.print("");
    }
    
    
    
    
    /** Constructor.
     * @param noCat The category for this NodeCategorizer.
     * @param dscr Description of this NodeCategorizer.
     * @param schema Schema for the data this categorizer classifies.
     */
    public NodeCategorizer(int noCat,  String dscr,  Schema schema) {
        super(noCat, dscr, schema);
        nodePtr = null;
        cGraph = null;
        smoothDistribution = false;
        smoothFactor = 0.0;
        lossInfo = new NodeLoss();
        
        //   DBG(checkGraph = true);
        reset_node_loss();
    }
    //used in NodeInfo.toString()
    /** Creates a String representation of this NodeCategorizer.
     * @return A String representation of this NodeCategorizer.
     */
    public String toString() {
        return description();
    }
    
    /** Clears the loss information.
     */
    public void reset_node_loss() {
        lossInfo.totalWeight = 0.0;
        lossInfo.totalLoss = 0.0;
        lossInfo.totalLossSquared = 0.0;
    }
    
    /** Returns TRUE if a graph has been set for this NodeCategorizer, FALSE otherwise.
     * @return TRUE if a graph has been set for this NodeCategorizer, FALSE otherwise.
     */
    public boolean in_graph()  { return (cGraph != null); }
    
    /** Splits the instance list according to the value returned by branch() for each
     * instance.
     * @param il The InstanceList to be split.
     * @return A array of partitions of the given InstanceList.
     */
    public  InstanceList[] split_instance_list( InstanceList il)
    
    {
        //   DBGSLOW(if (!get_schema().equal(il.get_schema()))
        //	   Error.err("NodeCategorizer::split_instance_list: my schema " +
        //			get_schema() + " is not the same as the schema of the instance list to split: " +
        //			il.get_schema() + "-->fatal_error");
        
        // Note num_cat() + 1, and NOT num_cat() because the count starts
        //   from UNKNOWN and not from FIRST.
        InstanceList[] ila =new InstanceList[num_categories() + 1];
        //(Globals.UNKNOWN_CATEGORY_VAL, num_categories() + 1);
        //   for (int i = ila.low(); i <= ila->high(); i++)
        for (int i = 0; i < ila.length; i++)
            ila[i] = new InstanceList(il.get_schema());
        for (ListIterator pix = il.instance_list().listIterator(); pix.hasNext();) {
            Instance instance = (Instance)pix.next();
            ila[branch(instance).num()].add_instance(instance);
            //ila[(int)(branch(instance))].add_instance(instance);
        }
        
        return ila;
    }
    
    /** Traverses the graph of nodes from this NodeCategorizer to determine the category
     * the given instance should be predicted as.
     * @param inst The instance for which a prediction is requested.
     * @return The category for the given instance.
     */
    abstract public AugCategory branch(Instance inst);
    
    
    /** Categorize an instance.
     * @param instance The instance to be categorized.
     * @return The category of the given instance.
     */
    public AugCategory categorize(Instance instance) {
        if (!in_graph())
            Error.fatalErr("NodeCategorizer::categorize: can only categorize from "
            +"inside a graph");
        return get_child_categorizer(instance).categorize(instance);
    }
    
    /** Returns TRUE if scoring supported by this node categorizer. TRUE is always
     * returned.
     * @return TRUE.
     */
    public  boolean supports_scoring()  { return true; }
    /** Score an instance. Scoring function contains the option of carrying the loss
     * information through the graph.
     * @param inst The instance to be scored.
     * @return The score of the given instance.
     */
    public  CatDist score( Instance inst){ return score(inst, false); }
    /** Score an instance. Scoring function contains the option of carrying the loss
     * information through the graph.
     * @param inst The instance to be scored.
     * @param addLoss TRUE if the loss information is to be carried through the graph, FALSE
     * otherwise.
     * @return The score of the given instance.
     */
    public  CatDist score( Instance inst, boolean addLoss) {
        if (!in_graph())
            Error.err("NodeCategorizer::score: can only score from inside a graph-->fatal_error");
        CatDist dist = get_child_categorizer(inst).score(inst, addLoss);
        // smoothing is not yet supported
        //      if (smoothDistribution) {
        //         Error.err("NodeCategorizer::score: smoothing is not yet supported-->fatal_error");
        //         dist.smooth_toward(get_distr(), smoothFactor);
        //      }
        if (addLoss)
            add_instance_loss(inst, dist);
        return dist;
    }
    
    /** Updates the loss information for this node to reflect the node's performance on
     * the given instance, and the given prediction.
     *
     * @param instance The instance to which given prediction applies.
     * @param pred The prediction of category distributions.
     */
    public  void add_instance_loss( Instance instance,
    CatDist pred) {
        int correctCat = Globals.UNKNOWN_CATEGORY_VAL;
        
        AugCategory predictedCat = pred.best_category();
        correctCat = instance.label_info().get_nominal_val(instance.get_label());
        if (correctCat == Globals.UNKNOWN_CATEGORY_VAL)
            Error.err("NodeCategorizer::add_instance_loss: instance " + instance + " has UNKNOWN_CATEGORY_VAL-->fatal_error");
        double loss;
        if (get_schema().has_loss_matrix())
            loss = get_schema().get_loss_matrix()[correctCat][predictedCat.num()];
        else if (predictedCat.num() == correctCat)
            loss = 0;
        else
            loss = 1;
        
        update_loss(instance.get_weight(), loss);
    }
    
    /** Returns the child categorizer of this node that is found by following the edge
     * with the given label.
     *
     * @param branch The category of the edge for which the child categorizer is requested.
     * @return The child categorizer.
     */
    public  NodeCategorizer get_child_categorizer(AugCategory branch) {
        Node childNode = get_graph().get_child(get_node(), branch);
        return ((NodeInfo)get_graph().entry(childNode)).get_categorizer();
    }
    
    /** Retrieves the appropriate categorizer one level down in the graph, obtained by
     * following the edge appropriate for the instance provided.
     *
     * @param inst The instance provided for determining which edge to traverse.
     * @return The child categorizer of the appropriate edge.
     */
    public  NodeCategorizer get_child_categorizer(Instance inst) {
        return get_child_categorizer(branch(inst));
    }
    
    /** Updates the loss information with the given values.
     * @param weight The new weight value.
     * @param loss The new loss value.
     */
    protected void update_loss(double weight, double loss) { lossInfo.update(weight, loss); }
    
    /** Returns the graph for this NodeCategorizer.
     * @return The graph for this NodeCategorizer.
     */
    protected  CGraph get_graph() {
        if (cGraph == null)
            Error.err("NodeCategorizer::get_graph: the graph is null-->fatal_error");
        return cGraph;
    }
    
    /** Returns the node for this NodeCategorizer.
     * @return The node for this NodeCategorizer.
     */
    protected Node get_node() {
        if (nodePtr == null)
            Error.err("NodeCategorizer::get_node: the node is null-->fatal_error");
        return nodePtr;
    }
    
    /** Recomputes the distribution of the categorizer according to the given instance
     * list, splits it, and redistributes the split lists among the child categorizers.
     * This process is used to backfit an instance list to a graph structure.
     *
     * @param il The instance list used for recomputation.
     * @param pruningFactor The amount of pruning being done.
     * @param pessimisticErrors The pessimistic Error value.
     * @param ldType Leaf distribution type.
     * @param leafDistParameter The leaf distribution.
     * @param parentWeightDist The weight distribution of the parent categorizer.
     * @param saveOriginalDistr TRUE if the original distribution should be preserved, FALSE otherwise.
     */
    public  void distribute_instances( InstanceList il,
    double pruningFactor,
    DoubleRef pessimisticErrors,
    int ldType,  			//TDDTInducer.LeafDistType
    double leafDistParameter,
    double[] parentWeightDist,
    boolean saveOriginalDistr) {
        CGraph myGraph = get_graph();
        Node myNode = get_node();
        if (myNode.outdeg() <= 0)
            Error.err("NodeCategorizer::distribute_instances: " +
            "this node has no children -- leaf categorizers " +
            "should be held inside a LeafCategorizer-->fatal_error");
        
        if (saveOriginalDistr && has_distr())
            set_original_distr(get_distr());
        build_distr(il);
        
        double[] myWeightDistribution = null;
        double[] augmentedWeightDist = null;
        
        if (il.no_weight())
            myWeightDistribution = parentWeightDist;
        else {
            double[] distrNoUnknown = get_distr();
            augmentedWeightDist = new double[distrNoUnknown.length + 1];
            //	 new Array<double>(UNKNOWN_CATEGORY_VAL, distrNoUnknown.size() + 1, 0);
            for (int i = 0; i < augmentedWeightDist.length; i++)
                augmentedWeightDist[i] = distrNoUnknown[i];
            myWeightDistribution = augmentedWeightDist;
        }
        
        InstanceList[] instLists = split_instance_list(il);
        //   forall_adj_edges(edgePtr, myNode) {
        for(Edge edgePtr = myNode.First_Adj_Edge(0);
        edgePtr != null;
        edgePtr = edgePtr.Succ_Adj_Edge(myNode)){
            int num = ((AugCategory)myGraph.inf(edgePtr)).num();
            Node child = edgePtr.target();
            //      ASSERT((instLists)[num]);
            NodeCategorizer childCat = ((NodeInfo)myGraph.inf(child)).get_categorizer();
            childCat.distribute_instances(instLists[num], pruningFactor,
            pessimisticErrors, ldType,
            leafDistParameter, myWeightDistribution,
            saveOriginalDistr);
            instLists[num] = null;
        }
        
        augmentedWeightDist = null;
        
        //   DBG(
        //       // Make sure we don't have any leftover instances or this is a bug
        //       for (Category cat = instLists->low(); cat <= instLists->high(); cat++)
        //          if ((instLists)[cat] != null)
        //	     // Maybe we don't have unknown edges
        //	     if ((instLists)[cat]->no_weight()) {
        //	        delete (instLists)[cat];
        //	        (instLists)[cat] = null;
        //	     } else
        //	        Error.err("NodeCategorizer::distribute_inst: Missed InstanceList " + cat + "-->fatal_error");
        //       );
        instLists = null;
    }
    
    /** Install the graph and node into the object.
     * @param aGraph The graph of NodeCategorizers.
     * @param aNode The node for this NodeCategorizer.
     */
    public void set_graph_and_node(CGraph aGraph, Node aNode) {
        if (aGraph == null || aNode == null)
            Error.err("NodeCategorizer::set_graph_and_node: neither the graph nor the node may be null-->fatal_error");
        if (cGraph != null || nodePtr != null)
            Error.err("NodeCategorizer::set_graph_and_node: the node and graph have already been set-->fatal_error");
        
        cGraph = aGraph;
        nodePtr = aNode;
        //   DBG(OK(0));
    }
    
    /** Returns the loss information.
     * @return The loss information.
     */
    public NodeLoss get_loss() { return lossInfo; }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产不卡视频一区| 久久精品夜色噜噜亚洲a∨| 国产自产v一区二区三区c| 亚洲高清在线精品| 亚洲欧美福利一区二区| 亚洲天堂成人网| 亚洲美女淫视频| 亚洲精品中文在线| 一区二区三区不卡在线观看 | 日韩精品91亚洲二区在线观看| 综合久久久久综合| 一区二区三区欧美亚洲| 亚洲一区二区欧美日韩 | 欧美一级黄色片| 欧美一区日本一区韩国一区| 欧美一级淫片007| 久久只精品国产| 亚洲人xxxx| 日韩不卡一区二区三区| 国产一区二区在线观看视频| 国产aⅴ综合色| 色噜噜偷拍精品综合在线| 欧美精品第一页| 国产三区在线成人av| 亚洲与欧洲av电影| 国产美女久久久久| 99精品视频在线免费观看| 99re亚洲国产精品| 欧美日韩在线播放| 777奇米成人网| 欧美日韩国产三级| 欧美一级久久久久久久大片| 精品国精品自拍自在线| 国产亚洲一本大道中文在线| 欧美激情一区二区三区全黄| 中文字幕在线视频一区| 亚洲综合偷拍欧美一区色| 国产精品久久久久久久久图文区 | 911国产精品| 精品国产一区二区三区四区四| 久久久久久久久久久久久女国产乱| 久久亚洲精华国产精华液| 日本一区二区电影| 亚洲一区二区精品久久av| 视频一区欧美精品| 婷婷综合在线观看| 激情都市一区二区| 94-欧美-setu| 91麻豆精品国产自产在线观看一区| 精品国产伦一区二区三区免费| 中文欧美字幕免费| 日本午夜精品一区二区三区电影| 久久国产日韩欧美精品| 成人毛片老司机大片| 欧美三级电影在线看| 2022国产精品视频| 亚洲曰韩产成在线| 成人一区二区三区视频在线观看| 在线影院国内精品| 久久久久97国产精华液好用吗| 亚洲综合图片区| 精品一区二区三区的国产在线播放| 99在线精品观看| 久久午夜国产精品| 亚洲一二三专区| 成人aaaa免费全部观看| 欧美日韩亚洲丝袜制服| 久久久久国产一区二区三区四区| 一区二区三区四区视频精品免费| 精品一区二区在线视频| 在线一区二区三区四区五区 | 免费观看91视频大全| 91在线国产福利| 欧美大片一区二区| 日韩国产在线观看一区| 在线欧美一区二区| 国产精品青草综合久久久久99| 热久久国产精品| 欧美性三三影院| 一区二区三区四区国产精品| 国产91在线看| 欧美mv和日韩mv的网站| 蜜桃久久av一区| 91.成人天堂一区| 一区二区三区在线播放| 欧美亚洲一区二区在线| 一区二区在线看| 一本到高清视频免费精品| 国产精品久久久久三级| 国产不卡在线视频| 久久久精品国产99久久精品芒果 | 欧美三日本三级三级在线播放| 国产精品久久久久一区二区三区| 国产精品资源在线| 中文字幕精品一区二区三区精品| 国产一区91精品张津瑜| 精品国产污网站| 国产乱人伦偷精品视频不卡| 国产精品无遮挡| 99视频精品在线| 一区二区三区美女| 波多野结衣在线aⅴ中文字幕不卡 波多野结衣在线一区 | 国产一区二区电影| 国产人久久人人人人爽| 粉嫩一区二区三区性色av| 日本一区二区三区在线不卡| 国产成人免费在线观看不卡| 国产精品乱码一区二区三区软件| 国产99久久久精品| 欧美国产精品一区二区| av不卡一区二区三区| 亚洲欧洲日韩一区二区三区| 91啪九色porn原创视频在线观看| 亚洲激情自拍视频| 制服丝袜中文字幕一区| 激情五月激情综合网| 国产精品区一区二区三区| 91蝌蚪porny九色| 五月婷婷综合网| 2020国产精品自拍| 91在线精品一区二区三区| 日本中文在线一区| 精品国精品自拍自在线| 激情五月激情综合网| 亚洲精品国产精品乱码不99 | 亚洲电影一级片| 精品精品欲导航| 99re这里只有精品6| 日本不卡中文字幕| 国产精品国产三级国产普通话99| 欧美性生活久久| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 国产91精品久久久久久久网曝门| 亚洲最大成人综合| 久久亚洲免费视频| 精品视频一区 二区 三区| 国产精品一二三四区| 亚洲成人一区二区在线观看| 久久精品人人做人人综合| 欧美日韩亚洲综合在线 | 国产精品夜夜嗨| 亚洲福利视频一区二区| 国产精品萝li| 日韩免费福利电影在线观看| 91在线观看视频| 老司机精品视频在线| 五月综合激情网| 亚洲色图制服丝袜| 欧美激情资源网| 欧美va在线播放| 91精品国产91久久综合桃花| 色综合欧美在线| 国产99久久久国产精品潘金| 日韩电影免费在线看| 亚洲精品国产视频| 国产精品青草久久| 国产欧美精品一区| 久久综合久久综合九色| 日韩美一区二区三区| 欧美人与性动xxxx| 欧美亚洲一区三区| 99在线精品视频| 国产精品白丝av| 91免费观看视频在线| 成人精品一区二区三区四区| 国产精品一二三在| 国产精品自拍网站| 国产黄色91视频| 狠狠色丁香久久婷婷综合_中| 蜜臀av亚洲一区中文字幕| 天天综合网 天天综合色| 亚洲国产日韩a在线播放性色| 亚洲精品乱码久久久久久| 亚洲免费在线播放| 夜夜嗨av一区二区三区网页| 亚洲自拍偷拍网站| 亚洲伊人色欲综合网| 亚洲一区成人在线| 亚洲一区二区三区美女| 久久99精品久久久久久久久久久久| 日韩激情在线观看| 久久99久久99小草精品免视看| 久久精品国产成人一区二区三区| 理论片日本一区| 国产高清久久久久| 岛国精品在线播放| 色婷婷综合久久久| 欧美精品丝袜中出| 欧美一级欧美三级| 久久精品一区二区三区av| 国产欧美日韩卡一| 亚洲女同ⅹxx女同tv| 亚洲综合在线观看视频| 婷婷国产v国产偷v亚洲高清| 天天射综合影视| 成人aaaa免费全部观看| 欧美日韩国产123区| 精品免费国产二区三区| 亚洲欧洲日本在线| 亚洲国产精品一区二区www在线|