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

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

?? nodecategorizer.java

?? 自己編的ID3算法很小但效果很好
?? 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一区二区三区免费野_久草精品视频
亚洲一卡二卡三卡四卡| 国产精品日韩精品欧美在线| 亚洲国产成人私人影院tom| 麻豆国产精品一区二区三区| 日韩视频一区二区三区在线播放| 亚洲va中文字幕| 日本欧美在线观看| 欧美一区二区三区四区高清 | 8x8x8国产精品| 日本成人在线不卡视频| 日韩欧美中文字幕一区| 国产最新精品精品你懂的| 国产女人aaa级久久久级 | 欧美日韩一区三区| 亚洲成人av中文| 日韩视频在线你懂得| 国产成人在线观看| 一区二区三区蜜桃| 3d动漫精品啪啪一区二区竹菊| 久久99国产精品成人| 国产欧美日韩精品a在线观看| 91偷拍与自偷拍精品| 午夜不卡在线视频| 欧美国产精品v| 在线视频中文字幕一区二区| 蜜桃视频免费观看一区| 自拍av一区二区三区| 欧美久久久久久久久久 | www..com久久爱| 亚洲综合丝袜美腿| 日韩欧美一级特黄在线播放| 粉嫩一区二区三区性色av| 亚洲午夜激情网站| 26uuu国产电影一区二区| 99re66热这里只有精品3直播| 日韩一区精品字幕| 国产精品色哟哟网站| 欧美色区777第一页| 国产一区二区三区在线观看精品 | 欧美大黄免费观看| 亚洲激情一二三区| 精品理论电影在线| 色婷婷国产精品| 国产精品一区一区三区| 丝袜美腿一区二区三区| 国产精品美女久久久久久久久 | 在线观看欧美黄色| 国产精品久久看| 欧美一二三四在线| 色吊一区二区三区| 高清国产午夜精品久久久久久| 亚洲线精品一区二区三区八戒| 久久影院午夜论| 欧美日韩亚洲综合| 91在线码无精品| 国产精品影视天天线| 久久精品久久99精品久久| 欧美人伦禁忌dvd放荡欲情| 成人手机在线视频| 国模冰冰炮一区二区| 午夜精品aaa| 亚洲精选视频在线| 中文字幕国产一区| 久久综合色8888| 欧美电视剧在线看免费| 7777精品伊人久久久大香线蕉经典版下载 | 欧美无砖专区一中文字| 97久久精品人人做人人爽| 国产成人在线色| 大白屁股一区二区视频| 国产在线麻豆精品观看| 久久国内精品视频| 日韩福利电影在线观看| 亚洲成a人v欧美综合天堂下载 | 亚洲成人精品影院| 亚洲综合成人网| 亚洲精品成人在线| 亚洲狠狠丁香婷婷综合久久久| 18涩涩午夜精品.www| 国产精品久久久久久久久免费桃花| 欧美岛国在线观看| 26uuu国产电影一区二区| 久久久久久久久久久久久久久99| 久久综合久久综合久久综合| 久久亚区不卡日本| 日本一区二区三区国色天香 | 日韩免费视频一区| 日韩精品中文字幕在线一区| 精品奇米国产一区二区三区| 精品久久五月天| 国产偷国产偷亚洲高清人白洁| 久久亚洲一级片| 国产女人aaa级久久久级 | 一区二区高清免费观看影视大全| 亚洲视频1区2区| 欧美丰满一区二区免费视频| 欧美老女人第四色| 日韩欧美www| 中文字幕日韩精品一区| 一区二区三区成人在线视频| 日韩欧美成人午夜| 国产精品系列在线| 一区二区三区国产精品| 免费欧美在线视频| 成人午夜大片免费观看| 欧美在线不卡一区| 欧美成人一级视频| 国产精品免费看片| 亚洲欧洲性图库| 偷拍一区二区三区| 国产精品自拍毛片| 色哟哟日韩精品| 欧美电视剧在线看免费| 日韩伦理av电影| 日韩高清在线观看| www.欧美.com| 日韩欧美精品在线| 亚洲精品国产无天堂网2021| 国内精品国产成人| 在线免费观看日本一区| 精品嫩草影院久久| 亚洲精品乱码久久久久久| 人禽交欧美网站| 不卡免费追剧大全电视剧网站| 欧美精品v国产精品v日韩精品| 久久综合给合久久狠狠狠97色69| 亚洲精品日韩一| 国产一区视频导航| 欧美日韩大陆一区二区| 久久影视一区二区| 午夜精品福利一区二区蜜股av| eeuss鲁一区二区三区| 精品毛片乱码1区2区3区| 亚洲精选一二三| 国产成人aaa| 91麻豆精品国产91久久久使用方法 | 中文字幕一区不卡| 美女精品一区二区| 欧美日韩专区在线| 国产精品丝袜黑色高跟| 麻豆国产一区二区| 欧美人动与zoxxxx乱| 亚洲视频一区二区在线| 国产精品一区二区在线观看不卡 | 国产69精品久久久久777| 欧美卡1卡2卡| 亚洲激情av在线| av在线免费不卡| 国产三级欧美三级| 精彩视频一区二区三区| 777午夜精品视频在线播放| 亚洲综合丁香婷婷六月香| 91在线国产福利| 国产精品久久久久永久免费观看 | 精品伊人久久久久7777人| 欧美性一二三区| 亚洲欧美精品午睡沙发| 国产精品一色哟哟哟| 国产欧美综合在线| 国产丶欧美丶日本不卡视频| 精品国产一区二区精华| 欧美bbbbb| 精品久久久久久久人人人人传媒| 亚洲综合视频网| 欧美日韩高清影院| 日韩国产在线观看| 欧美一卡2卡3卡4卡| 蜜臀精品久久久久久蜜臀| 欧美日本在线播放| 午夜精品久久久久久不卡8050| 91福利资源站| 樱桃国产成人精品视频| 欧洲av一区二区嗯嗯嗯啊| 亚洲国产日韩一级| 欧美精品一二三区| 日韩欧美自拍偷拍| 精品午夜久久福利影院| 精品国产乱码久久| 激情深爱一区二区| 国产三级三级三级精品8ⅰ区| 成人午夜激情在线| 欧美日韩国产另类不卡| 日本麻豆一区二区三区视频| 精品欧美一区二区在线观看| 国产成人精品午夜视频免费| 国产精品剧情在线亚洲| 色综合色狠狠天天综合色| 亚洲第一久久影院| 欧美成人国产一区二区| 韩日精品视频一区| 中文字幕免费观看一区| 色呦呦网站一区| 日本免费新一区视频| 久久午夜免费电影| 91视频在线观看免费| 日韩国产成人精品| 久久久久久久网| 色婷婷综合久久久久中文| 免播放器亚洲一区| 国产精品麻豆99久久久久久|