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

📄 algorithmed.java,v

📁 包含了模式识别中常用的一些分类器设计算法
💻 JAVA,V
📖 第 1 页 / 共 2 页
字号:
1.9log@Javadoc comments are up to standard.@text@d37 1a37 1    Vector support_vectors_d;
d42 1a42 1    Vector decision_regions_d;
d58 4a61 4	decision_regions_d = new Vector();
	point_means_d = new Vector();
	support_vectors_d = new Vector();
	description_d = new Vector();
d87 9a95 4	set1_d = (Vector)data_points_d.dset1.clone();
	set2_d = (Vector)data_points_d.dset2.clone();
	set3_d = (Vector)data_points_d.dset3.clone();
	set4_d = (Vector)data_points_d.dset4.clone();
d101 1a101 1	// append message to process box
d104 1@1.8log@*** empty log message ***@text@d4 2a5 1//                          Last Edited :  Sanjay Patil
d24 3d29 3d33 4d38 4d49 1a49 1     * @@return  boolean
d108 1a108 1     * @@return  boolean
d147 1a147 1     * @@return  boolean
d180 1a180 1     * @@return  boolean
@1.7log@*** empty log message ***@text@d2 3a4 2// AlgorithmED.java V6.0 03/15/2005
// Created Phil Trasatti, Edited Daniel May. Last Edited Sanjay Patil
@1.6log@few more finer changes to the comments to comply with the Java Documentationstyle. Further more, all the changes are consistent with the previous file.@text@d18 1a18 2 * Inherits base class Algorithm. class implements the euclidean distance
 * algorithm.
@1.5log@rectified a spelling mistake for ompute as Compute.@text@d1 9a9 10/**
* AlgorithmED.java V6.0 03/15/2005
*
* Author: Phil Trasatti, last edited : Daniel May Created: 7/15/03
*
* Class: AlgorithmED
* 
* Description: Euclidean Distance algoritm.  Inherits base class Algorithm
* Determines the line of discrimination between data sets.
*/
d17 4a20 1
a22 13
    //-----------------------------------------------------------------
    //
    // static data members
    //
    //-----------------------------------------------------------------

    //-----------------------------------------------------------------
    //
    // primitive data members
    //
    //-----------------------------------------------------------------

a24 6    //-----------------------------------------------------------------
    //
    // instance data members
    //
    //-----------------------------------------------------------------
        
d28 1a28 3	  
     // class methods

a29 1     *
a34 1     *
d87 1a87 2	return true;
	
a90 1     *
a93 1     *
a128 1     *
a132 1     * 
d151 2a152 1	output_panel_d.addOutput(support_vectors_d, Classify.PTYPE_INPUT, Color.black);
a162 1     *
a165 1     * 
a193 1    *
a195 1    *
a229 1    *
a230 1    *
d337 2a338 1		    dist = MathUtil.distance(pixel.x, pixel.y, point.x, point.y);
d374 1a374 3     *
     * Computes and displays the classification errors for each set   
     *
d378 1a378 1	//Debug
d413 13a425 14	    {
		
		MyPoint point = (MyPoint)set1_d.elementAt(i);
		samples1++;
		if ((point.x > scale.xmin && point.x < scale.xmax)
		    && (point.y > scale.ymin && point.y < scale.ymax))
		    {
			if (output_canvas_d[(int)((point.x - scale.xmin) / 
                            incrementX)][(int)((point.y - scale.ymin) / 
                            incrementY)] != 0)
			    {
				incorrect1++;
			    }
		    }
d427 1d430 1a430 1	    {
d432 17a448 17		error = ((double)incorrect1 / (double)samples1) * 100.0;
		
		text =
		    new String(
			       "       Results for class 0:\n"
			       + "          Total number of samples: "
			       + samples1
			       + "\n"
			       + "          Misclassified samples: "
			       + incorrect1
			       + "\n"
			       + "          Classification error: "
			       + MathUtil.setDecimal(error, 2)
			       + "%");
		
		pro_box_d.appendMessage(text);
	    }
d453 13a465 14	    {
		
		MyPoint point = (MyPoint)set2_d.elementAt(i);
		samples2++;
		if ((point.x > scale.xmin && point.x < scale.xmax)
		    && (point.y > scale.ymin && point.y < scale.ymax))
		    {
			if (output_canvas_d[(int)((point.x - scale.xmin) / 
                            incrementX)][(int)((point.y - scale.ymin) / 
                            incrementY)] != 1)
			    {
				incorrect2++;
			    }
		    }
d467 1d470 19a488 19	    {
		
		error = ((double)incorrect2 / (double)samples2) * 100.0;
		
		text =
		    new String(
			       "       Results for class 1:\n"
			       + "          Total number of samples: "
			       + samples2
			       + "\n"
			       + "          Misclassified samples: "
			       + incorrect2
			       + "\n"
			       + "          Classification error: "
			       + MathUtil.setDecimal(error, 2)
			       + "%");
		
		pro_box_d.appendMessage(text);
	    }
d493 13a505 14	    {
		
		MyPoint point = (MyPoint)set3_d.elementAt(i);
		samples3++;
		if ((point.x > scale.xmin && point.x < scale.xmax)
		    && (point.y > scale.ymin && point.y < scale.ymax))
		    {
			if (output_canvas_d[(int)((point.x - scale.xmin) / 
                            incrementX)][(int)((point.y - scale.ymin) / 
                            incrementY)] != 2)
			    {
				incorrect3++;
			    }
		    }
d507 1d510 19a528 19	    {
		
		error = ((double)incorrect3 / (double)samples3) * 100.0;
		
		text =
		    new String(
			       "       Results for class 2:\n"
			       + "          Total number of samples: "
			       + samples3
			       + "\n"
			       + "          Misclassified samples: "
			       + incorrect3
			       + "\n"
			       + "          Classification error: "
			       + MathUtil.setDecimal(error, 2)
			       + "%");
		
		pro_box_d.appendMessage(text);
	    }
d533 13a545 14	    {
		
		MyPoint point = (MyPoint)set4_d.elementAt(i);
		samples4++;
		if ((point.x > scale.xmin && point.x < scale.xmax)
		    && (point.y > scale.ymin && point.y < scale.ymax))
		    {
			if (output_canvas_d[(int)((point.x - scale.xmin) / 
                            incrementX)][(int)((point.y - scale.ymin) / 
                            incrementY)] != 3)
			    {
				incorrect4++;
			    }
		    }
d547 1d550 19a568 19	    {
		
		error = ((double)incorrect4 / (double)samples4) * 100.0;
		
		text =
		    new String(
			       "       Results for class 3:\n"
			       + "          Total number of samples: "
			       + samples4
			       + "\n"
			       + "          Misclassified samples: "
			       + incorrect4
			       + "\n"
			       + "          Classification error: "
			       + MathUtil.setDecimal(error, 2)
			       + "%");
		
		pro_box_d.appendMessage(text);
	    }
@1.4log@Thinks this will be the final version for Java Documentation.For the parameters passed and returned are none, that line is omitted.@text@d405 1a405 1     * omputes and displays the classification errors for each set   
@1.3log@changed comments as per Java Documentation.Refer http://java.sun.com/j2se/javadoc/writingdoccomments/index.html@text@d2 1a2 1* AlgorithmED.java
d4 1a4 5* Created: 7/15/03
*
* Author: Phil Trasatti
* 
* Last Edited by: Daniel May
d46 7a52 1    /**
d54 1a54 1     * class methods
a56 12
    /** 
    * method: initialize
    *
    * @@param   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.
    */
d60 2a61 1	//System.out.println(algo_id + ": initialize()");
d71 1d88 1d92 1d99 1d103 1d107 1d113 6a118 9    * method: step1
    *
    * @@param   none
    * @@return  boolean
    *
    * description:  
    * displays data sets from input box in output box.
    * 
    */
d122 2a123 1	//System.out.println(algo_id + " : step1()");
d126 1d134 1d145 1d153 7a159 10    * method: step2
    *
    * @@param   none
    * @@return  boolean
    *
    * description:  
    * computes the means of each data set and displays the means graphically
    * and numerically
    * 
    */
d163 2a164 1	//System.out.println(algo_id + " : step2()");
d167 1d169 1d171 1a171 1	//----
d176 1a176 1	//----
d188 6a193 9    * method: step3
    *
    * @@param   none
    * @@return  boolean
    *
    * description:   
    * Computes the Decision Regions and the associated errors. 
    * 
    */    
d197 2a198 1	//System.out.println(algo_id + " : step3()");
d201 1a201 1	//----
d209 3a211 2	//----
	output_panel_d.addOutput( decision_regions_d, Classify.PTYPE_INPUT, new Color(255, 200, 0));
d216 1a216 1	
a220 1    * method: run
d222 2a223 2    * @@param   none
    * @@return  none
a224 3    * description: 
    * implementation of the run function from the Runnable interface.
    * determines what the current step is and calls the appropriate method.
d229 2a230 1	//System.out.println(algo_id + " : run()");
a258 4    * method: computeDecisionRegions
    *
    * @@param   none
    * @@return  none
d260 1a260 2    * description:
    * computes the line of discrimination    
d266 3a268 1	//System.out.println(algo_id +": computeDecisionRegions()");
d270 1a270 1
d275 1d301 1a301 1
a339 1				
a346 1				
a353 1				
d393 2a394 1		    if (associated != output_canvas_d[i][j - 1] || associated != output_canvas_d[i - 1][j])
d404 4a407 9    * method: computeErrors
    *
    * @@param   none
    * @@return  none
    *
    * description:
    * computes and displays the classification errors for each set   
    *
    */   
d411 2a412 1	//System.out.println(algo_id +": computeErrors()");
d430 2a431 1	DisplayScale scale = output_panel_d.disp_area_d.getDisplayScale();	
d433 1d437 1a437 1	double incrementY = (scale.ymax-scale.ymin)/outputHeight;
d439 1a439 1	double incrementX = (scale.xmax-scale.xmin)/outputWidth;
d452 3a454 1			if (output_canvas_d[(int)((point.x-scale.xmin)/incrementX)][(int)((point.y-scale.ymin)/incrementY)] != 0)
d492 3a494 1			if (output_canvas_d[(int)((point.x-scale.xmin)/incrementX)][(int)((point.y-scale.ymin)/incrementY)] != 1)
d532 3a534 1			if (output_canvas_d[(int)((point.x-scale.xmin)/incrementX)][(int)((point.y-scale.ymin)/incrementY)] != 2)
d572 3a574 1			if (output_canvas_d[(int)((point.x-scale.xmin)/incrementX)][(int)((point.y-scale.ymin)/incrementY)] != 3)
d604 1a604 1	samples = samples1 + samples2 + samples3 + samples4;
d606 1a606 1	error = ((double)incorrect / (double)samples) * 100.0;
d622 1a622 4	
    }    
    
    
@1.2log@All the debug statements commented out.End of the sequence will be now "Algorithm Complete"@text@d1 14a14 14//----------------------------------------------------------------------
// AlgorithmED.java
//
// Created: 7/15/03
//
// Author: Phil Trasatti
// 
// Last Edited by: Daniel May
//
// Class: AlgorithmED
// 
// Description: Euclidean Distance algoritm.  Inherits base class Algorithm
// Determines the line of discrimination between data sets.
//---------------------------------------------------------------------
d50 17a66 18    //---------------------------------------------------------------
    //
    // class methods
    //
    //---------------------------------------------------------------


    //---------------------------------------------------------------
    // 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.
    //---------------------------------------------------------------
d115 10a124 10    //---------------------------------------------------------------
    // method: step1
    //
    // arguments: none
    // return   : boolean
    //
    // description:  
    // displays data sets from input box in output box.
    // 
    //---------------------------------------------------------------
d154 11a164 11    //---------------------------------------------------------------
    // method: step2
    //
    // arguments: none
    // return   : boolean
    //
    // description:  
    // computes the means of each data set and displays the means graphically
    // and numerically
    // 
    //---------------------------------------------------------------
d189 10a198 10    //---------------------------------------------------------------
    // method: step3
    //
    // arguments: none
    // return   : boolean
    //
    // description:   
    // Computes the Decision Regions and the associated errors. 
    // 
    //---------------------------------------------------------------    
d223 10a232 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.
    //--------------------------------------------------------------- 
d264 10a273 10    // --------------------------------------------------------------
    // method: computeDecisionRegions
    //
    // arguments: none
    // return   : none
    //
    // description:
    // computes the line of discrimination    
    //
    //--------------------------------------------------------------
d412 11a422 10    //--------------------------------------------------------------
    // method: computeErrors
    //
    // arguments: none
    // return   : none
    //
    // description:
    // computes and displays the classification errors for each set   
    //
    //--------------------------------------------------------------   
@1.1log@Initial revision@text@d71 1a71 1	System.out.println(algo_id + ": initialize()");
d129 1a129 1	System.out.println(algo_id + " : step1()");
d169 1a169 1	System.out.println(algo_id + " : step2()");
d203 1a203 1	System.out.println(algo_id + " : step3()");
d237 1a237 1	System.out.println(algo_id + " : run()");
d257 1a257 1		pro_box_d.appendMessage("   Step Sequence Complete");
d278 1a278 1	System.out.println(algo_id +": computeDecisionRegions()");
d426 1a426 1	System.out.println(algo_id +": computeErrors()");
@

⌨️ 快捷键说明

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