⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 totalsupporttree.java

📁 多关联分类算法
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	    }	}*/        /* GENERATE ASSOCIATION RULES */        /** Generates all association rules for a given large item set found in a    T-tree structure. <P> Called from <TT>generateARs</TT> method.    @param itemSet the given large itemset.    @param support the associated support value for the given large itemset. */        /*private void generateARsFromItemset(short[] itemSet, double support) {    	// Determine combinations	short[][] combinations = combinations(itemSet);		// Loop through combinations	for(int index=0;index<combinations.length;index++) {            // Find complement of combimation in given itemSet	    short[] complement = complement(combinations[index],itemSet);	    // If complement is not empty generate rule	    if (complement != null) {	        double confidenceForAR = getConfidence(combinations[index],		    						support);		if (confidenceForAR >= confidence) {		       currentRlist.insertRuleintoRulelist(combinations[index],		     				   complement,confidenceForAR);		    }		} 	    }	}*/	    /*----------------------------------------------------------------------- */    /*                                                                        */    /*                                GET METHODS                             */    /*                                                                        */    /*----------------------------------------------------------------------- */        /* GET CONFIDENCE */        /** Calculates and returns the conidence for an AR given the antecedent    item set and the support for the total item set.    @param antecedent the antecedent (LHS) of the AR.    @param support the support for the large itemset from which the AR is    generated.    @return the associated confidence value. */        protected double getConfidence(short[] antecedent, double support) {        // Get support forantecedent        double supportForAntecedent = (double)				getSupportForItemSetInTtree(antecedent);					// Return confidence	double confidenceForAR = ((double) support/supportForAntecedent)*10000;	int tempConf = (int) confidenceForAR;	confidenceForAR = (double) tempConf/100;	return(confidenceForAR); 	}    /* GET CONFIDENCE */        /** Calculates and returns the conidence for an AR given the support for     both the antecedent and the entire item set.    @param antecedentSupp the support for antecedent (LHS) of the AR.    @param totalSupp the support for the large itemset from which the AR is    generated.    @return the associated confidence value. */        protected double getConfidence(double antecedentSupp, double totalSupp) {        // Return confidence	double confidenceForAR = ((double) totalSupp/antecedentSupp)*10000;	int tempConf = (int) confidenceForAR;	confidenceForAR = (double) tempConf/100;	return(confidenceForAR); 	}    	    /* GET START OF T-TRRE */        /** Returns the reference to the start of the T-tree.    @return The start of the T-tree. */        /*public TtreeNode[] getStartOfTtree() {    	return(startTtreeRef);	}  */	    /* GET NUMBER OF FREQUENT SETS */    /** Returns number of frequent/large (supported) sets in T-tree.    @return the number of supporte sets. */        public int getNumFreqSets() {        // If emtpy tree (i.e. no supported sets) do nothing	if (startTtreeRef ==  null) return(0);			// Loop	int num=0;	for (int index=1; index <= numOneItemSets; index++) {	    // Check for null valued top level Ttree node.	    if (startTtreeRef[index] !=null) {	        if (startTtreeRef[index].support >= minSupport) 			num = countNumFreqSets(index,	    				startTtreeRef[index].childRef,num+1);		}	    }		// Output	return(num);	}    /* GET NUMBER OF FREQUENT ONE ITEM SETS */    /** Returns number of frequent/large (supported) one itemsets in T-tree.    @return the number of supporte ine itemsets. */        /*public int getNnumFreqOneItemSets() {	return(numOneItemSets);	}*/	    /* GET MINIMUM SUPPORT VALUE */    /** Returns the minimum support threshold value in terms of a number     records.    @return the minimum support value. */        public double getMinSupport() {	return(minSupport);	}    /* GET CURRENT RULE LIST OBJECT */	   	    /** Gets the current instance of the RuleList class.    @return the current RuleList object. */    public RuleList getCurrentRuleListObject() {        return(currentRlist);	}				    /*----------------------------------------------------------------------- */    /*                                                                        */    /*                              UTILITY METHODS                           */    /*                                                                        */    /*----------------------------------------------------------------------- */        /* SET NUMBER ONE ITEM SETS */        /** Sets the number of one item sets field (<TT>numOneItemSets</TT> to     the number of supported one item sets. */        public void setNumOneItemSets() {        numOneItemSets=getNumSupOneItemSets();	}	    /* COUNT T-TREE NODES */        /** Commences process of counting the number of nodes in the T-tree. <P>     Not the same as counting the number of nodes created as some of these may     have been pruned.     @return the number of nodes. */        /*protected int countNumberOfTtreeNodes() {        int counter = 0;		// Loop		for (int index=1; index < startTtreeRef.length; index++) {	    if (startTtreeRef[index] !=null) {	        counter++;	        counter = countNumberOfTtreeNodes(counter,						startTtreeRef[index].childRef);		}	    }            	// Return	return(counter);	}   */        /* COUNT T-TREE NODES IN N SUB-BRANCHES*/        /** Commences process of counting the number of nodes in a sequence of    T-tree sub-branches.      @return the number of nodes. */        /*private int countNumTtreeNodesInNbranches(int startIndex, int endIndex) {        int counter = 0;		// Loop		for (int index=startIndex; index <= endIndex; index++) {	    if (startTtreeRef[index] !=null) {	        counter++;	        counter = countNumberOfTtreeNodes(counter,						startTtreeRef[index].childRef);		}	    }            	// Return	return(counter);	}    */	    /** Continues process of counting number of nodes in a T-tree.    @param counter the count sofar.    @param linkref the reference to the current location in the T-tree.    @return the updated count. */        /*private int countNumberOfTtreeNodes(int counter,TtreeNode[] linkRef) {        // Check for empty branch/sub-branch.	if (linkRef == null) return(counter);		// Loop through current level of branch/sub-branch.	for (int index=1;index<linkRef.length;index++) {	    if (linkRef[index] != null) {	        counter++;	        counter = countNumberOfTtreeNodes(counter,						linkRef[index].childRef); 		}	    }            	// Return	return(counter);    	}      */    /** Counts number of nodes in T-tree at level N.    @param counter the count sofar.    @param level the required level.    @param linkref the reference to the current location in the T-tree.    @return the updated count. */        /*private int countNumTtreeNodesLevelN(int counter, int level,    		TtreeNode[] linkRef) {        // No nodes in this sub-branch level?	if (linkRef == null) return(counter);		// If at right level count nodes with support of 1 or more	if (level == 1) {	    for(int index=1;index<linkRef.length;index++) {	        if ((linkRef[index] != null) && (linkRef[index].support>0)) 								counter++;	        }	    }	    	// If at wrong level proceed down child branches	else {	    for (int index=1;index<linkRef.length;index++) {	        if (linkRef[index] != null) counter = 	    			countNumTtreeNodesLevelN(counter,level-1,						linkRef[index].childRef); 		}	    }            	// Return	return(counter);    	}            */		 	    /*----------------------------------------------------------------------- */    /*                                                                        */    /*                              OUTPUT METHODS                            */    /*                                                                        */    /*----------------------------------------------------------------------- */      /* Nine output options:        (1)  Output T-tree    (2)  Output T-tree branch    (3)  Output frequent sets (also GUI version)    (4)  Output number of frequent sets    (5)  Output number of frequent sets per T-tree branch    (6)  T-tree statistics    (7)  Output number of updates and nodes created    (8)  Output T-tree storage     (9)  Output serialization array     (10) Output serialized T-tree array (with support vlaues)    (11) Output serialized T-tree array (no support vlaues)     (12) Output serialized T-tree for level N */        /* ---------------- */    /* 1. OUTPUT T-TRRE */    /* ---------------- */    /** Commences process of outputting T-tree structure contents to screen. */	        public void outputTtree() {	int number = 1;		// Loop		for (int index=1; index < startTtreeRef.length; index++) {	    if (startTtreeRef[index] !=null) {	        System.out.print("[" + number + "] {" + index);	        System.out.println("} = " + startTtreeRef[index].support);	        outputTtree(new Integer(number).toString(),			new Integer(index).toString(),			startTtreeRef[index].childRef);		number++;		}	    }    	}	    /** Continue process of outputting T-tree. <P> Operates in a recursive     manner.    @param number the ID number of a particular node.    @param itemSetSofar the label for a T-treenode as generated sofar.    @param linkRef the reference to the current array lavel in the T-tree. */        private void outputTtree(String number, String itemSetSofar,    				TtreeNode[] linkRef) {	// Set output local variables.	int num=1;	number = number + ".";	itemSetSofar = itemSetSofar + " ";		// Check for empty branch/sub-branch.	if (linkRef == null) return;		// Loop through current level of branch/sub-branch.	for (int index=1;index<linkRef.length;index++) {	    if (linkRef[index] != null) {	        System.out.print("[" + number + num + "] {" + itemSetSofar +	    		index);	        System.out.println("} = " + linkRef[index].support);	        String newitemSet = itemSetSofar + 						new Integer(index).toString();	        outputTtree(number + num,newitemSet,linkRef[index].childRef); 	        num++;		}	    }    	}	    /* ----------------------- */    /* 2. OUTPUT T-TREE BRANCH */    /* ----------------------- */    /** Commences process of outputting contents of a given T-tree branch to    screen.    @param linkRef the reference to the start of the branch*/	        public void outputTtreeBranch(TtreeNode[] linkRef) {	int number = 1;		// Check for empty tree		if (linkRef == null) return;		// Loop		for (int index=1; index<linkRef.length; index++) {	    if (linkRef[index] !=null) {	        System.out.print("[" + number + "] {" + index);	        System.out.println("} = " + linkRef[index].support);	        outputTtree(new Integer(number).toString(),			new Integer(index).toString(),linkRef[index].childRef);		number++;		}	    }    	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -