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

📄 algorithmlbg.java,v

📁 包含了模式识别中常用的一些分类器设计算法
💻 JAVA,V
📖 第 1 页 / 共 3 页
字号:
		enableControl();
	    }
d336 5a340 5	    {
		disableControl();
		step2(); 
		enableControl();
	    }
d343 6a348 6	    {
		disableControl();
		step3();
		enableControl();
	    }

d353 4a356 1
d388 1a388 1	// add all points from the forth data set
a396 1    * 
a401 1    *
d418 1a418 1	int i=0;
d488 3a655 1    * 
d658 1a658 2    * @@param  DecisionRegion region: classified data sets
    *
a707 1     *
d713 3a715 2     * @@return   : standard deviation of the cluster
     *
a754 1     * 
d757 1a757 2     * @@param DecisionRegion region: stored data sets from the classification
     *
d806 6a811 8    * 
    * Computes the k-mean decision region - nearest neighbor algorithm
    *
    * @@param   Vector vec: vector of initial guesses
    *
    * @@return  vector of desision region points
    *
    */
a816 1
d829 2a830 2	double incrementY = (scale.ymax-scale.ymin)/outputHeight;
	double incrementX = (scale.xmax-scale.xmin)/outputWidth;
d852 2a853 1		MyPoint pixel = new MyPoint(currentX, currentY);	                       smallestSoFar = Double.MAX_VALUE;
d925 2a926 1			    MyPoint mean4 = (MyPoint)point_means_d.elementAt(l);
d969 4@1.4log@some errors done during Java Style Documentation were rectified.@text@d2 1a2 1* AlgorithmLBG.java
d4 1a4 8* Created: 7/15/03
*
* Author: Phil Trasatti
* 
* @@author Daniel May
*
* Class: AlgorithmLBG
* 
a53 1    * method: initialize
d55 4a58 1    * @@param  none
a60 4    * description:  
    * overrides the initialize() method in the base class.  initializes
    * member data and prepares for execution of first step.  this method
    * "resets" the algorithm.
d65 2a66 1	//System.out.println(algo_id + ": initialize()");
d81 1d101 1d105 1d112 1d116 1d120 1a125 1    * method: step1
d127 2a128 1    * @@param  none
a129 3    *
    * description:  
    * displays data sets from input box in output box.
d135 2a136 1	//System.out.println(algo_id + " : step1()");
d139 1d147 1d158 1d166 8a173 10    * method: step2
    *
    * @@param  none
    * @@return   boolean
    *
    * description:  
    * computes the means of each data set and displays the means graphically
    * and numerically
    * 
    */
d177 2a178 1	//System.out.println(algo_id + " : step2()");
d181 1d200 1a200 1	//cbinary_d.addElement(decision_regions_d);	
d209 6a214 9    * method: step3
    *
    * @@param  none
    * @@return boolean
    *
    * description:   
    * Computes the Decision Regions and the associated errors. 
    * 
    */
d218 2a219 1	//System.out.println(algo_id + " : step3()");
d224 2a225 1	    pro_box_d.appendMessage("      Iteration " + (currObject+1) + "\n");	
d254 2a255 1	    for (int i=0; i<numclusters; i++) {
d282 2a283 1		for (int j=0; j<cluster.size(); j++) {
d310 5a314 5		message = new String("      Covariance matrix:\n" +
				     "         " + c11 
				     + "    " + c12 + "\n" +
				     "         " + c21 
				     + "    " + c22);
d334 6a339 6					 "          Total number of samples: " + 
					 total + "\n" +
					 "          Misclassified samples: " + 
					 error + "\n" +
					 "          Classification error: " + 
					 MathUtil.setDecimal(err, 2) + "%");
a349 1    * method: run
d351 2a352 2    * @@param  none
    * @@return none
a353 3    * description: 
    * implementation of the run function from the Runnable interface.
    * determines what the current step is and calls the appropriate method.
d358 2a359 1	//System.out.println(algo_id + " : run()");
d381 1d387 2a388 1    public void generatePool() {
d392 2a393 1	if (data_pool_d.size() > 0) {
d399 2a400 1	for (int i=0; i<set1_d.size(); i++) {	    
d406 2a407 1	for (int i=0; i<set2_d.size(); i++) {	    
d413 2a414 1	for (int i=0; i<set3_d.size(); i++) {	    
d420 2a421 1	for (int i=0; i<set4_d.size(); i++) {	    
d427 2a428 1    * method: getClosestSet
a433 2    * method determines the closest data sets to the cluster
    *
d435 2a436 1    public int getClosestSet(MyPoint mean) {
d496 2a497 1	if (dist1 < dist2 && dist1 < dist3 && dist1 < dist4) {
d503 2a504 1	if (dist2 < dist1 && dist2 < dist3 && dist2 < dist4) {
d510 2a511 1	if (dist3 < dist1 && dist3 < dist2 && dist3 < dist4) {
d520 2a521 1    public int displayClusterError(int closest, Vector cluster, int id) {
d532 4a535 4	if (closest == 1) {

	    for (int i=0; i<cluster.size(); total++, i++) {

d544 2a545 1		for (int j=0; j<set1_d.size(); j++) {
d553 2a554 1		    if (cst.x == pnt.x && cst.y == pnt.y) {
d561 2a562 1		if (!present) {
d570 4a573 4	if (closest == 2) {

	    for (int i=0; i<cluster.size(); total++, i++) {

d582 2a583 2		for (int j=0; j<set2_d.size(); j++) {

d590 2a591 1		    if (cst.x == pnt.x && cst.y == pnt.y) {
d598 2a599 1		if (!present) {
d607 4a610 4	if (closest == 3) {

	    for (int i=0; i<cluster.size(); total++, i++) {

d619 2a620 2		for (int j=0; j<set3_d.size(); j++) {

d627 2a628 1		    if (cst.x == pnt.x && cst.y == pnt.y) {
d635 2a636 1		if (!present) {
d644 4a647 4	if (closest == 4) {

	    for (int i=0; i<cluster.size(); total++, i++) {

d656 2a657 2		for (int j=0; j<set4_d.size(); j++) {

d664 2a665 1		    if (cst.x == pnt.x && cst.y == pnt.y) {
d672 2a673 1		if (!present) {
d685 2a686 1    * method: computeBinaryDeviates
a689 4    * @@return none
    *
    * method computes the binary deviates after each iteraion
    *
d691 2a692 1    public void computeBinaryDeviates(Vector decisionRegions) {
d704 2a705 2	for (int i=0; i<numsets; i++) {

d708 3a710 1	    Vector dataset = (Vector)((DataSet)decisionRegions.elementAt(i)).getDataSet();
d739 11a749 11    * method: clusterDeviation
    *
    * @@param  Vector cluster: cluster of data points
    * @@param  Point: mean of the cluster
    *
    * @@return   : standard deviation of the cluster
    *
    * method to calculate the standard deviation of the cluster 
    *
    */
    public MyPoint clusterDeviation(Vector cluster, MyPoint mean) {
d758 2a759 2	for (int i=0; i<cluster.size(); i++) {

d786 8a793 10    * method: classify
    * 
    * @@param DecisionRegion region: stored data sets from the classification
    *
    * @@return none
    *
    * method classifies the data sets based on the k-means iterative algorithm
    *
    */
    public void classify(Vector guesses) {
d797 2a798 2	for (int i=0; i<data_pool_d.size(); i++) {

d811 2a812 2	    for (int j=0; j<guesses.size(); j++) {

d823 2a824 1		if(dist < smallestSoFar) {
d839 2a840 1    * method: getDecisionRegion
d842 1a842 1    * @@param  Vector vec: vector of initial guesses
a845 2    * computes the k-mean decision region - nearest neighbor algorithm
    *
d847 2a848 1    public Vector getDecisionRegion(Vector vec) {
d877 2a878 2	for(int i = 0; i < outputWidth; i++) {
	    
d884 2a885 2	    for(int j = 0; j < outputHeight; j++) {
		
d892 2a893 2		for (int k = 0; k < vec.size(); k++) {

d897 2a898 1		    dist = MathUtil.distance(pixel.x, pixel.y, point.x, point.y); 
d900 2a901 2		    if(dist < smallestSoFar) {
			
d907 4a910 2			if(set1_d.size() > 0) {
			    MyPoint mean1 = (MyPoint)point_means_d.elementAt(l);
d913 3a915 2					     mean1.x, mean1.y); 
			    if(cdist < smallest) {			    
d924 4a927 2			if(set2_d.size() > 0) {
			    MyPoint mean2 = (MyPoint)point_means_d.elementAt(l);
d930 3a932 2					     mean2.x, mean2.y); 
			    if(cdist < smallest) {
d941 4a944 2			if(set3_d.size() > 0) {
			    MyPoint mean3 = (MyPoint)point_means_d.elementAt(l);
d947 3a949 2					     mean3.x, mean3.y); 
			    if(cdist < smallest) {
d958 2a959 1			if(set4_d.size() > 0) {
d963 3a965 2					     mean4.x, mean4.y); 
			    if(cdist < smallest) {
d987 2a988 1		if(j > 0 && i > 0) {
d990 2a991 1		       associated != outputCanvas[i - 1][j]) {
a1027 1
a1028 1
a1029 1    
a1030 14













@1.3log@changed the comments (few). The lot of documentation needs to be done.the comments comply with Java Documentation format.@text@d237 2a238 2	    * compute the new means of the classified data
	    *
d662 1a662 1	* @@return the misclassified samples
@1.2log@Algorithm Complete and debug statements commented@text@d1 13a13 13//----------------------------------------------------------------------
// AlgorithmLBG.java
//
// Created: 7/15/03
//
// Author: Phil Trasatti
// 
// Last Edited by: Daniel May
//
// Class: AlgorithmLBG
// 
// 
//---------------------------------------------------------------------
d60 11a70 11    //---------------------------------------------------------------
    // method: initialize
    //
    // arguments: none
    // return   : boolean
    //
    // description:  
    // overrides the initialize() method in the base class.  initializes
    // member data and prepares for execution of first step.  this method
    // "resets" the algorithm.
    //---------------------------------------------------------------
d127 10a136 10    //---------------------------------------------------------------
    // method: step1
    //
    // arguments: none
    // return   : boolean
    //
    // description:  
    // displays data sets from input box in output box.
    // 
    //---------------------------------------------------------------
d166 11a176 11    //---------------------------------------------------------------
    // method: step2
    //
    // arguments: none
    // return   : boolean
    //
    // description:  
    // computes the means of each data set and displays the means graphically
    // and numerically
    // 
    //---------------------------------------------------------------
d209 10a218 10    //---------------------------------------------------------------
    // method: step3
    //
    // arguments: none
    // return   : boolean
    //
    // description:   
    // Computes the Decision Regions and the associated errors. 
    // 
    //---------------------------------------------------------------    
d237 2a238 2	    // compute the new means of the classified data
	    //
d349 10a358 10    //---------------------------------------------------------------
    // method: run
    //
    // arguments: none
    // return   : none
    //
    // description: 
    // implementation of the run function from the Runnable interface.
    // determines what the current step is and calls the appropriate method.
    //--------------------------------------------------------------- 
d422 10a431 10    
    // method: getClosestSet
    //
    // arguments: 
    //    Point mean: mean of the cluster
    // 
    // return   : closest data set to the cluster
    //
    // method determines the closest data sets to the cluster
    //
d662 1a662 1	// return the misclassified samples
d667 10a676 9    // method: computeBinaryDeviates
    // 
    // arguments:
    //    DecisionRegion region: classified data sets
    //
    // return   : none
    //
    // method computes the binary deviates after each iteraion
    //
d720 12a731 11
    // method: clusterDeviation
    //
    // arguments:
    //    Vector cluster: cluster of data points
    //    Point: mean of the cluster
    //
    // return   : standard deviation of the cluster
    //
    // method to calculate the standard deviation of the cluster 
    //
d768 10a777 9    // method: classify
    // 
    // arguments:
    //    DecisionRegion region: stored data sets from the classification
    //
    // return   : none
    //
    // method classifies the data sets based on the k-means iterative algorithm
    //
d822 10a831 9    // method: getDecisionRegion
    //
    // arguments: 
    //    Vector vec: vector of initial guesses
    //
    // return   : vector of desision region points
    //
    // computes the k-mean decision region - nearest neighbor algorithm
    //
@1.1log@Initial revision@text@d74 1a74 1	System.out.println(algo_id + ": initialize()");
d140 1a140 1	System.out.println(algo_id + " : step1()");
d180 1a180 1	System.out.println(algo_id + " : step2()");
d222 1a222 1	System.out.println(algo_id + " : step3()");
d362 1a362 1	System.out.println(algo_id + " : run()");
@

⌨️ 快捷键说明

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