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

📄 totalsupporttree.java

📁 多关联分类算法
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        /* ----------------------- */ 	    /* 3. OUTPUT FREQUENT SETS */    /* ----------------------- */    /** Commences the process of outputting the frequent sets contained in     the T-tree. */	        public void outputFrequentSets() {	int number = 1;		System.out.println("FREQUENT (LARGE) ITEM SETS:\n" +	                    	"---------------------------");		// Loop		for (int index=1; index <= numOneItemSets; index++) {	    if (startTtreeRef[index] !=null) {	        if (startTtreeRef[index].support >= minSupport) {	            System.out.println("[" + number + "] {" + index + "} = " + 		    				startTtreeRef[index].support);	            number = outputFrequentSets(number+1,		    			new Integer(index).toString(),		    			index,startTtreeRef[index].childRef);		    }		}	    }    		// End		System.out.println("\n");	}    /** Outputs T-tree frequent sets. <P> Operates in a recursive manner.    @param number the number of frequent sets so far.    @param itemSetSofar the label for a T-treenode as generated sofar.    @param size the length/size of the current array lavel in the T-tree.    @param linkRef the reference to the current array lavel in the T-tree.     @return the incremented (possibly) number the number of frequent sets so     far. */        private int outputFrequentSets(int number, String itemSetSofar, int size,    							TtreeNode[] linkRef) {		// No more nodes		if (linkRef == null) return(number);		// Otherwise process		itemSetSofar = itemSetSofar + " ";	for (int index=1; index < size; index++) {	    if (linkRef[index] != null) {	        if (linkRef[index].support >= minSupport) {	            System.out.println("[" + number + "] {" + itemSetSofar + 		    		index +"} = " + linkRef[index].support);	            String newitemSet = itemSetSofar + 		    			new Integer(index).toString();	            number = outputFrequentSets(number + 1,newitemSet,index,		    			linkRef[index].childRef); 	            }		}	    }    		// Return		return(number);	}        /* OUTPUT FREQUENT SETS (GUI VERSION) */    /** Commences the process of outputting the frequent sets contained in     the T-tree to a rext area.     @param the text area. */                    public void outputFrequentSets(JTextArea textArea) {	int number = 1;		textArea.append("FREQUENT (LARGE) ITEM SETS:\n" +	                	"---------------------------\n");		// Loop		for (int index=1; index <= numOneItemSets; index++) {	    if (startTtreeRef[index] !=null) {	        if (startTtreeRef[index].support >= minSupport) {	            textArea.append("[" + number + "] {" + index + "} = " + 		    			startTtreeRef[index].support + "\n");	            number = outputFrequentSets(textArea,number+1,		    			new Integer(index).toString(),		    			index,startTtreeRef[index].childRef);		    }		}	    }    		// End		textArea.append("\n");	}    /** Outputs T-tree frequent sets. <P> Operates in a recursive manner.    @param the text area.    @param number the number of frequent sets so far.    @param itemSetSofar the label for a T-treenode as generated sofar.    @param size the length/size of the current array lavel in the T-tree.    @param linkRef the reference to the current array lavel in the T-tree.     @return the incremented (possibly) number the number of frequent sets so     far. */        private int outputFrequentSets(JTextArea textArea, int number,     			String itemSetSofar, int size, TtreeNode[] linkRef) {		// No more nodes		if (linkRef == null) return(number);		// Otherwise process		itemSetSofar = itemSetSofar + " ";	for (int index=1; index < size; index++) {	    if (linkRef[index] != null) {	        if (linkRef[index].support >= minSupport) {	            textArea.append("[" + number + "] {" + itemSetSofar + 		    		index +"} = " + linkRef[index].support + "\n");	            String newitemSet = itemSetSofar + 		    			new Integer(index).toString();	            number = outputFrequentSets(textArea,number + 1,newitemSet,		    			index,linkRef[index].childRef); 	            }		}	    }    		// Return		return(number);	}	    /* ------------------------------ */    /* 4. OUTPUT NUMBER FREQUENT SETS */    /* ------------------------------ */    /** Commences the process of counting and outputing number of supported     nodes in the T-tree.<P> A supported set is assumed to be a non null node in    the T-tree. */    public void outputNumFreqSets() {		// If emtpy tree (i.e. no supported sets) do nothing	if (startTtreeRef== null) System.out.println("Number of frequent " +					"sets = 0");	// Otherwise count and output	else System.out.println("Number of frequent sets = " + 					countNumFreqSets());	}        /* COUNT NUMBER OF FRQUENT SETS */    /** Commences process of counting the number of frequent (large/supported    sets conayoned in the T-tree. */        protected int countNumFreqSets() {        // If emtpy tree return 0	if (startTtreeRef ==  null) return(0);		// Otherwise loop through T-tree starting with top level	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);		}	    }    		// Return	return(num);	}	    /** Counts the  number of supported nodes in a sub branch of the T-tree.    @param size the length/size of the current array lavel in the T-tree.    @param linkRef the reference to the current array lavel in the T-tree.    @param num the number of frequent serts sofar. */    protected int countNumFreqSets(int size, TtreeNode[] linkRef, int num) {		if (linkRef == null) return(num);		for (int index=1; index < size; index++) {	    if (linkRef[index] != null) {	        if (linkRef[index].support >= minSupport) 	            			num = countNumFreqSets(index,					linkRef[index].childRef,num+1);		}	    }		// Return		return(num);	}        /* --------------------------------------------------- */    /* 5. OUTPUT NUMBER OF FREQUENT SETS PER T-TREE BRANCH */    /* --------------------------------------------------- */    /** Outputs the number of supported sets per T-tree branch descending from     the top-level of the tree. <P> Used for diagnostic purposes. */        public void outputNumFreqSetsPerBranch() { 		System.out.println("Number of frequent sets per branch");		for (int index=1; index <= numOneItemSets; index++) {	    if (startTtreeRef[index] !=null) {	        System.out.println("(" + index + ")" + countNumFreqSets(index,					startTtreeRef[index].childRef,1));		}	   	    }	}	    /* --------------------------- */    /* 6. OUTPUT T-TREE STATISTICS */    /* --------------------------- */    /** Commences the process of outputting T-tree statistics (for diagnostic    purposes): (a) Storage, (b) Number of nodes on P-tree, (c) number of    partial support increments (updates) and (d) generation time. */        public void outputTtreeStats() {        System.out.println("T-TREE STATISTICS\n-----------------");		System.out.println(calculateStorage() + " (Bytes) storage");	System.out.println(TtreeNode.getNumberOfNodes() + " nodess");	System.out.println(countNumFreqSets() + " frequent sets");	System.out.println(numUpdates + " support value increments");	System.out.println(duration);	}	    /** Commences the process of outputting T-tree statistics:GUI version.    @param the text area. */        public void outputTtreeStats(JTextArea textArea) {        textArea.append("T-TREE STATISTICS\n-----------------\n");		textArea.append(calculateStorage() + " (Bytes) storage\n");	textArea.append(TtreeNode.getNumberOfNodes() + " nodess\n");	textArea.append(countNumFreqSets() + " frequent sets\n");	textArea.append(numUpdates + " support value increments\n");	textArea.append(duration + "\n");	}	    /* --------------------------- */    /* 7. OUTPUT NUMBER OF UPDATES */    /* --------------------------- */    /** Commences the process of determining and outputting the storage    requirements (in bytes) for the T-tree */    /** Outputs the number of update and number of nodes created during the    generation of the T-tree (the later is not the same as the number of     supported nodes). */        public void outputNumUpdates() {	System.out.println("Number of Nodes created = " + 			TtreeNode.getNumberOfNodes());	System.out.println("Number of Updates       = " + numUpdates);	} 		    /* ----------------- */    /* 8. OUTPUT STORAGE */    /* ----------------- */    /** Commences the process of determining and outputting the storage    requirements (in bytes) for the T-tree. <P> Example: Given ---    <PRE>        	{1,2,3}     		{1,2,3}		{1,2,3}    		{1,2,3}		{1,2,3}    </PRE>    This will produce a T-tree as shown below:	    <PRE>    +---+---+---+---+ 		    | 0 | 1 | 2 | 3 |	    +---+---+---+---+          |   |   |	  |   |   +-----------+	  |   |               |	  |   +---+         +---+---+---+              |       |         | 0 | 1 | 2 |	( 5 )   +---+---+   +---+---+---+	(nul)   | 0 | 1 |         |   |	        +---+---+         |   +----+		      |           |        |		      |           |      +---+---+		    ( 5 )         |      | 0 + 1 |		    (nul)       ( 5 )    +---+---+	                        (nul)          |				               |					     ( 5 )					     (nul)        </PRE>					         0 elements require 4 bytes of storage, null nodes (not shown above) 4 bytes     of storage, others 12 bytes of storage.			*/        public void outputStorage() {		// If emtpy tree (i.e. no supported serts) do nothing	if (startTtreeRef ==  null) return;			/* Otherwise calculate stoarge */	System.out.println("T-tree Storage          = " + calculateStorage() + 			" (Bytes)");	} 	       /* CALCULATE STORAGE */    /** Commences process of claculating storage requirements for  T-tree. */        protected int calculateStorage() {        // If emtpy tree (i.e. no supported serts) return 0	if (startTtreeRef ==  null) return(0);			/* Step through top level */		int storage = 4;	// For element 0	for (int index=1; index <= numOneItemSets; index++) {	    if (startTtreeRef[index] !=null) storage = storage + 12 + 	    		calculateStorage(0,startTtreeRef[index].childRef);	    else storage = storage+4;	    }	// Return	return(storage);	}            /** Calculate storage requirements for a sub-branch of the T-tree.    @param localStorage the storage as calculated sofar (set to 0 at start).    @param linkRef the reference to the current sub-branch of the T-tree. */        private int calculateStorage(int localStorage, TtreeNode[] linkRef) {		if (linkRef == null) return(0);		for (int index=1; index < linkRef.length; index++) {	    if (linkRef[index] !=null) localStorage = localStorage + 12 + 	    		calculateStorage(0,linkRef[index].childRef);	    else localStorage = localStorage + 4;	    }            	 /* Return */	 	 return(localStorage+4);	// For element 0	 }    }        

⌨️ 快捷键说明

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