示例#1
0
  /** Reports the results obtained */
  public void printReport() {

    writeOutput(outFile[0], trainOutput, trainPrediction);
    writeOutput(outFile[1], testOutput, testPrediction);

    ReportTool.setResults(trainOutput, trainPrediction, testOutput, testPrediction, nClasses);

    ReportTool.printReport();

    /*
    DecimalFormat nf4;

    nf4 = (DecimalFormat) DecimalFormat.getInstance();
    nf4.setMaximumFractionDigits(4);
    nf4.setMinimumFractionDigits(0);

    DecimalFormatSymbols dfs = nf4.getDecimalFormatSymbols();

    dfs.setDecimalSeparator('.');
    nf4.setDecimalFormatSymbols(dfs);

    String text="\n\n====================\n";

    text+="Prototypes:\n";

    for(int i=0;i<centroids.length;i++){
    	if(nInstances[i]>0){
    		text+=(i+1)+": ";
    		for(int j=0;j<inputAtt;j++){
    			text+= " "+nf4.format(centroids[i][j]);
    		}
    		text+="\n";
    	}
    }

    text+="\n\nReference set membership:\n";

    for(int i=0;i<referenceData.length;i++){
    	text+=(i+1)+": ";
    	for(int j=0;j<nClasses;j++){
    		text+="Class "+(j+1)+": "+nf4.format(membership[i][j])+"\t";
    	}
    	text+="\n";
    }

    /*text+="\n\nTest set membership:\n";

    for(int i=0;i<testData.length;i++){
    	text+=(i+1)+": ";
    	for(int j=0;j<nClasses;j++){
    		text+="Class "+(j+1)+": "+nf4.format(testMembership[i][j])+"\t";
    	}
    	text+="\n";
    }

    ReportTool.addToReport(text);*/

  } // end-method
示例#2
0
  /**
   * Main builder. Initializes the methods' structures
   *
   * @param script Configuration script
   */
  public FCMKNN(String script) {

    readDataFiles(script);

    // Naming the algorithm
    name = "Fuzzy C-Means K-NN";

    centroids = new double[nClasses][inputAtt];
    membership = new double[trainData.length][nClasses];

    referenceMembership = new double[referenceData.length][nClasses];
    testMembership = new double[testData.length][nClasses];

    // Initialization of random generator
    Randomize.setSeed(seed);

    // Initialization of Reporting tool
    ReportTool.setOutputFile(outFile[2]);
  } // end-method