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

📄 algorithmlda2.java,v

📁 包含了模式识别中常用的一些分类器设计算法
💻 JAVA,V
📖 第 1 页 / 共 5 页
字号:
d67 4a70 4	point_means_d = new Vector();
	decision_regions_d = new Vector();
	support_vectors_d = new Vector();
	description_d = new Vector();
d113 9a121 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();
@1.6log@java documentation comments style.@text@d55 1a55 1    * @@return   boolean
d132 1a132 1    * @@return boolean
d166 2d237 2d306 4a309 4     * @@param   M1 : covariance matrix of the first class
     * @@param   M2 : covariance matrix of the second class
     * @@param   M3 : covariance matrix of the third class
     * @@param   M4 : covariance matrix of the fourth class
d634 1a634 1     * @@param   M : Matrix storing within class scatter matrix
d1048 4a1051 4     * @@param   M1: between class scatter matrix for the first class
     * @@param   M2: between class scatter matrix for the second class
     * @@param   M3: between class scatter matrix for the third class
     * @@param   M4: between class scatter matrix for the fourth class
@1.5log@minor changesclear@text@d1 12a12 5/*
 * AlgorithmLDA2.java v6.0 03/15/2005 
 * Author Phil Trasatti Created on Jul 15, 2003
 */

d16 3d50 7a56 3    /* (non-Javadoc)
     * @@see IFAlgorithm#initialize()
     */
d72 10a81 10	W = new Matrix();
	B1 = new Matrix();
	B2 = new Matrix();
	B3 = new Matrix();
	B4 = new Matrix();
	S1 = new Matrix();
	S2 = new Matrix();
	S3 = new Matrix();
	S4 = new Matrix();
	CLDA = new Matrix();
d86 1a86 1	invW = new Matrix();
a108 1	    
d129 5d162 5d232 4d264 4a298 1     * 
d302 5a306 5     * @@param   Matrix M1: covariance matrix of the first class
     * @@param   Matrix M2: covariance matrix of the second class
     * @@param   Matrix M3: covariance matrix of the third class
     * @@param   Matrix M4: covariance matrix of the forth class
     *
a627 1     * 
d630 2a631 2     * @@param   Matrix M: within class scatter matrix
     *
a856 1     *
a857 1     *
d888 2a889 2	double incrementY = (scale.ymax-scale.ymin)/outputHeight;
	double incrementX = (scale.xmax-scale.xmin)/outputWidth;
a1040 1     *
d1044 4a1047 5     * @@param   Matrix M1: between class scatter matrix for the first class
     * @@param   Matrix M2: between class scatter matrix for the second class
     * @@param   Matrix M3: between class scatter matrix for the third class
     * @@param   Matrix M4: between class scatter matrix for the forth class
     *
d1331 1a1331 1	// compute the between class scatter contribution of the forth set
d1352 5d1558 4@1.4log@minor changes.@text@d268 10a277 10    * 
    * Transforms a given set of points to a new space
    * using the class dependent linear discrimination analysis algorithm
    *
    * @@param   Matrix M1: covariance matrix of the first class
    * @@param   Matrix M2: covariance matrix of the second class
    * @@param   Matrix M3: covariance matrix of the third class
    * @@param   Matrix M4: covariance matrix of the forth class
    *
    */
d541 1a541 1	// compute the transformation matrix for the forth data set
d1346 1d1348 1d1435 1a1435 2	{
	    
d1450 1a1450 2	{
	    
d1472 1a1472 2	{
	    
d1487 1a1487 2	{
	    
@1.3log@nothing major. Changes made to suit Java Documentation Style. and IFC style of coding.@text@d1 5a7 3/*
 * Created on Jul 15, 2003
 */
a8 4/**
 * @@author Phil Trasatti
 *
 */
d47 3a49 2	    // Debug
	    //System.out.println(algo_id + ": initialize()");
d75 1d92 1d97 1d104 1d108 1d112 1d119 2a120 1	//System.out.println(algo_id + ": step1()");
d127 1d136 1d138 1d147 2a148 1	//System.out.println(algo_id + ": step2()");
d164 3a166 3		// determine the ratio of the between class scatter matrix
		// to the within class scatter matrix
		//
d193 3a195 2	//----
	output_panel_d.addOutput(point_means_d, Classify.PTYPE_OUTPUT_LARGE, Color.black);
d198 3a200 2	//----
	output_panel_d.addOutput(support_vectors_d, Classify.PTYPE_INPUT, Color.cyan);
d219 1a219 1	//----
d222 2a223 2		// compute errors
		//
d227 4a230 1	output_panel_d.addOutput( decision_regions_d, Classify.PTYPE_INPUT, new Color(255, 200, 0));
a231 1	//Color.black);
d240 2a241 1	//System.out.println(algo_id + " run()");
d266 1d268 3a270 1    * method transformLDA1
a271 1    * @@param   Data d: input data point
a276 4    * @@return  none
    *
    * this method transforms a given set of points to a new space
    * using the class dependent linear discrimination analysis algorithm
d312 1a312 1		// declare arrays for the eigenvalues
d318 2a319 2		// declare an array to store the eigen vectors
		//
d324 2a325 1	double maxsamples = set1_d.size() + set2_d.size() + set3_d.size() + set4_d.size();
a339 1	    
a348 1	    
d405 1a405 2	{
	    
d414 1a414 2	{
	    
d430 1a430 1		W.col = 2;
d432 22a453 19		// reset the matrices
		//
		W.resetMatrix();
		    
		// initialize the matrix needed to compute the eigenvalues
		//
		T.initMatrix(S2.Elem, 2, 2);
		    
		// make a copy of the original matrix
		//
		M.copyMatrix(T);
		    
		// compute the eigen values
		//
		eigVal2 = Eigen.compEigenVal(T);
		    
		// compute the eigen vectors
		//
		for (int i = 0; i < 2; i++)
d455 1a455 5		    Eigen.calcEigVec(M, eigVal2[i], eigVec);
		    for (int j = 0; j < 2; j++)
		    {
			W.Elem[j][i] = eigVec[j];
		    }
a456 4		
		// save the transformation matrix 
		//
		LDA2 = W;
d458 6a463 1		
d470 1a470 2	{
	    
d479 29a507 1	{
d509 12a520 42		// declare matrix objects
		//
		Matrix T = new Matrix();
		Matrix M = new Matrix();
		Matrix W = new Matrix();
		    
		// allocate memory for the matrix elements
		//
		T.Elem = new double[2][2];
		M.Elem = new double[2][2];
		W.Elem = new double[2][2];
		    
		// initialize the transformation matrix dimensions
		//
		W.row = 2;
		W.col = 2;
		    
		// reset the matrices
		//
		W.resetMatrix();
		    
		// initialize the matrix needed to compute the eigenvalues
		//
		T.initMatrix(S3.Elem, 2, 2);
		    
		// make a copy of the original matrix
		//
		M.copyMatrix(T);
		    
		// compute the eigen values
		//
		eigVal3 = Eigen.compEigenVal(T);
		    
		// compute the eigen vectors
		//
		for (int i = 0; i < 2; i++)
	        {
		    Eigen.calcEigVec(M, eigVal3[i], eigVec);
		    for (int j = 0; j < 2; j++)
		    {
	       		W.Elem[j][i] = eigVec[j];
	      	    }
d522 5a526 4		
		// save the transformation matrix 
		//
		LDA3 = W;
d535 1a535 2	{
	    
d598 2a599 1     * method: withinClass
a600 1     * @@param   Data d: input data points
a602 4     * @@return  none
     *
     * this method determines the within class scatter matrix
     *
d620 2a621 1	double maxsamples = set1_d.size() + set2_d.size() + set3_d.size() + set4_d.size();
a826 10       // method computeMeans
       //
       // param:
       //   Data d: input data point
       //
       //  return   : none
       //
       // display two matrices
       //

a827 4     * method: computeDecisionRegions
     *
     * @@param  none
     * @@return none
d835 2a836 1	//System.out.println(algo_id + ": computeDecisionRegions()");
d839 1a862 1	//compute the line of discrimination for class dependent LDA
a869 1	
a907 1		    
d980 2a981 1		    dist = MathUtil.distance(C.Elem[0][0], C.Elem[0][1], D.Elem[0][0], D.Elem[0][1]);
d1003 2a1004 1		    if (associated != output_canvas_d[i][j - 1] || associated != output_canvas_d[i - 1][j])
a1013 1     * method: betweenClass1
d1015 3a1017 1     * @@param   Data d: input data points
a1022 5     * @@return  none
     *
     * this method determines the between class scatter matrix for
     * the class dependent linear discrimination algorithm
     *
d1059 2a1060 1	double maxsamples = set1_d.size() + set2_d.size() + set3_d.size() + set4_d.size();
a1133 1	    
a1169 1		
a1175 1		
a1181 1		
a1190 1	    
a1197 1		
a1203 1		
a1209 1		
d1218 1a1218 2       	{
	    
d1249 1a1249 2	{
	    
d1269 1a1269 2       	{
	    
d1289 1a1289 2	{
	    
d1309 1a1309 2	{
	    
a1328 1	
d1350 2a1351 2	double incrementY = (scale.ymax-scale.ymin)/outputHeight;
	double incrementX = (scale.xmax-scale.xmin)/outputWidth;
d1363 2a1364 1		if (output_canvas_d[(int)((point.x-scale.xmin)/incrementX)][(int)((point.y-scale.ymin)/incrementY)] != 0)
a1372 1	    
d1401 2a1402 1		if (output_canvas_d[(int)((point.x-scale.xmin)/incrementX)][(int)((point.y-scale.ymin)/incrementY)] != 1)
d1440 2a1441 1		if (output_canvas_d[(int)((point.x-scale.xmin)/incrementX)][(int)((point.y-scale.ymin)/incrementY)] != 2)
d1479 2a1480 1		if (output_canvas_d[(int)((point.x-scale.xmin)/incrementX)][(int)((point.y-scale.ymin)/incrementY)] != 3)
a1527 1	
a1643 1
a1644 1
@1.2log@"Algorithm Complete" added and debug statements commented.@text@d13 35a47 35
	Vector decision_regions_d;
	Vector support_vectors_d;
	int output_canvas_d[][];

	// declare local matrix objects
	Matrix W;
	Matrix B1;
	Matrix B2;
	Matrix B3;
	Matrix B4;
	Matrix S1;
	Matrix S2;
	Matrix S3;
	Matrix S4;
	Matrix invW;

	Matrix LDA1;
	Matrix LDA2;
	Matrix LDA3;
	Matrix LDA4;

	Matrix CLDA1; // covariance matrix for CLDA1
	Matrix CLDA2; // covariance matrix for CLDA2
	Matrix CLDA3; // covariance matrix for CLDA3
	Matrix CLDA4; // covariance matrix for CLDA4

	Matrix CLDA; // covariance matrix for CLDA

	/* (non-Javadoc)
	 * @@see IFAlgorithm#initialize()
	 */
	public boolean initialize()
	{
	    algo_id = "AlgorithmLDA2";
d51 29a79 23	    step_count = 3;
	    point_means_d = new Vector();
	    decision_regions_d = new Vector();
	    support_vectors_d = new Vector();
	    description_d = new Vector();
	    
	    // create local matrix objects
	    //
	    W = new Matrix();
	    B1 = new Matrix();
	    B2 = new Matrix();
	    B3 = new Matrix();
	    B4 = new Matrix();
	    S1 = new Matrix();
	    S2 = new Matrix();
	    S3 = new Matrix();
	    S4 = new Matrix();
	    CLDA = new Matrix();
	    CLDA1 = new Matrix();
	    CLDA2 = new Matrix();
	    CLDA3 = new Matrix();
	    CLDA4 = new Matrix();
	    invW = new Matrix();
d81 5a85 15	    // Add the process description for the LDA algorithm
	    if (description_d.size() == 0)
		{
		    String str = new String("   0. Initialize the original data.");
		    description_d.addElement(str);
		    
		    str = new String("   1. Displaying the original data.");
		    description_d.addElement(str);
		    
		    str = new String("   2. Computing the means and covariance.");
		    description_d.addElement(str);
		    
		    str = new String("   3. Computing the decision regions based on the class dependent LDA algorithm.");
		    description_d.addElement(str);
		}
d87 6a92 2	    // append message to process box
	    pro_box_d.appendMessage("Class Dependent LDA Analysis:" + "\n");
d95 5a99 5	    // set the data points for this algorithm
	    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 2a102 2	    // set the step index
	    step_index_d = 0;
d104 2a105 2

⌨️ 快捷键说明

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