/** * initializes the matrix with the values from the given matrix. * * @param matrix the matrix to get the values from */ public ResultMatrix(ResultMatrix matrix) { assign(matrix); }
/** * removes the stored data and the ordering, but retains the dimensions of the * matrix. */ public void clear() { m_MeanPrec = getDefaultMeanPrec(); m_StdDevPrec = getDefaultStdDevPrec(); m_ShowStdDev = getDefaultShowStdDev(); m_ShowAverage = getDefaultShowAverage(); m_RemoveFilterName = getDefaultRemoveFilterName(); m_PrintColNames = getDefaultPrintColNames(); m_PrintRowNames = getDefaultPrintRowNames(); m_EnumerateColNames = getDefaultEnumerateColNames(); m_EnumerateRowNames = getDefaultEnumerateRowNames(); m_RowNameWidth = getDefaultRowNameWidth(); m_ColNameWidth = getDefaultColNameWidth(); m_MeanWidth = getDefaultMeanWidth(); m_StdDevWidth = getDefaultStdDevWidth(); m_SignificanceWidth = getDefaultSignificanceWidth(); m_CountWidth = getDefaultCountWidth(); setSize(getColCount(), getRowCount()); }
/** * sets the mean at the given position (if the position is valid). * * @param col the column of the mean * @param row the row of the mean * @param value the value of the mean */ public void setMean(int col, int row, double value) { if ((col >= 0) && (col < getColCount()) && (row >= 0) && (row < getRowCount())) { m_Mean[row][col] = value; } }
/** * returns the number of visible columns. * * @return the number of columns */ public int getVisibleColCount() { int cols; int i; cols = 0; for (i = 0; i < getColCount(); i++) { if (!getColHidden(i)) { cols++; } } return cols; }
matrix.addHeader("header1", "value1"); matrix.addHeader("header2", "value2"); matrix.addHeader("header2", "value3"); for (i = 0; i < matrix.getRowCount(); i++) { for (n = 0; n < matrix.getColCount(); n++) { matrix.setMean(n, i, (i+1)*n); matrix.setStdDev(n, i, ((double) (i+1)*n) / 100); if (i == n) { if (i % 2 == 1) matrix.setSignificance(n, i, SIGNIFICANCE_WIN); else matrix.setSignificance(n, i, SIGNIFICANCE_LOSS); System.out.println("\n\n--> " + matrix.getDisplayName()); System.out.println(matrix.toStringHeader() + "\n"); System.out.println(matrix.toStringMatrix() + "\n"); System.out.println(matrix.toStringKey()); matrix.setShowStdDev(true); System.out.println(matrix.toStringMatrix()); matrix.setPrintColNames(false); System.out.println(matrix.toStringMatrix()); matrix.setColHidden(1, true); System.out.println(matrix.toStringMatrix());
rows = getVisibleRowCount(); if (getShowAverage()) { rows++; cols = getVisibleColCount(); if (getShowStdDev()) { cols = cols * 3; // mean + stddev + sign. } else { result[0][0] = trimString("Dataset", getRowNameWidth()); x = 1; for (ii = 0; ii < getColCount(); ii++) { i = getDisplayCol(ii); if (getColHidden(i)) { continue; result[0][x] = trimString(removeFilterName(getColName(i)), getColNameWidth()); x++; if (getShowStdDev()) { result[0][x] = ""; x++; for (ii = 0; ii < getRowCount(); ii++) { i = getDisplayRow(ii); if (!getRowHidden(i)) { result[y][0] = trimString(removeFilterName(getRowName(i)), getRowNameWidth());
m_ResultMatrix.setRowOrder(m_SortOrder); m_ResultMatrix.setColOrder(m_ColOrder); m_ResultMatrix.setMeanWidth(maxWidthMean); m_ResultMatrix.setStdDevWidth(maxWidthStdDev); m_ResultMatrix.setSignificanceWidth(1); for (int i = 0; i < m_ResultMatrix.getColCount(); i++) { if ((i == baseResultset) && (m_ResultMatrix.getColHidden(i))) { m_ResultMatrix.setColHidden(i, false); System.err.println("Note: test base was hidden - set visible!"); m_ResultMatrix.setRowName(i, templateString(m_DatasetSpecifiers.specifier(i))); m_ResultMatrix.setCount(i, pairedStats.count); m_ResultMatrix.setMean(j, i, pairedStats.yStats.mean); m_ResultMatrix.setStdDev(j, i, pairedStats.yStats.stdDev); m_ResultMatrix.setSignificance(j, i, ResultMatrix.SIGNIFICANCE_WIN); } else if (pairedStats.differencesSignificance > 0) { m_ResultMatrix .setSignificance(j, i, ResultMatrix.SIGNIFICANCE_LOSS); } else { m_ResultMatrix.setSignificance(j, i, ResultMatrix.SIGNIFICANCE_TIE); result.append(m_ResultMatrix.toStringMatrix()); } catch (Exception e) {
/** * counts the occurrences of the given significance type in the given column. * * @param col the columnn to gather the information from * @param type the significance type, WIN/TIE/LOSS * @return the count */ public int getSignificanceCount(int col, int type) { int result; int i; result = 0; if ((col >= 0) && (col < getColCount())) { for (i = 0; i < getRowCount(); i++) { if (getRowHidden(i)) { continue; } // no value? if (Double.isNaN(getMean(col, i))) { continue; } if (getSignificance(col, i) == type) { result++; } } } return result; }
/** * returns the average of the mean at the given position, if the position is * valid, otherwise 0. * * @param col the column index * @return the average */ public double getAverage(int col) { int i; double avg; int count; if ((col >= 0) && (col < getColCount())) { avg = 0; count = 0; for (i = 0; i < getRowCount(); i++) { if (!Double.isNaN(getMean(col, i))) { avg += getMean(col, i); count++; } } return avg / count; } else { return 0; } }
/** * returns the name of the row, if the index is valid, otherwise null. if * getPrintColNames() is FALSE then an empty string is returned or if * getEnumerateColNames() is TRUE then the 1-based index surrounded by * parentheses. * * @param index the index of the column * @return the name of the column * @see #setPrintColNames(boolean) * @see #getPrintColNames() * @see #setEnumerateColNames(boolean) * @see #getEnumerateColNames() */ public String getColName(int index) { String result; result = null; if ((index >= 0) && (index < getColCount())) { if (getPrintColNames()) { result = m_ColNames[index]; } else { result = ""; } if (getEnumerateColNames()) { result = LEFT_PARENTHESES + Integer.toString(index + 1) + RIGHT_PARENTHESES + " " + result; result = result.trim(); } } return result; }
int n; setSize(matrix.getColCount(), matrix.getRowCount());
/** * sets the name of the column (if the index is valid). * * @param index the index of the column * @param name the name of the column */ public void setColName(int index, String name) { if ((index >= 0) && (index < getColCount())) { m_ColNames[index] = name; } }
/** * returns the displayed index of the given col, depending on the order of * columns, returns -1 if index out of bounds. * * @param index the column to get the displayed index for * @return the real index of the column */ public int getDisplayCol(int index) { if ((index >= 0) && (index < getColCount())) { if (getColOrder() == null) { return index; } else { return getColOrder()[index]; } } else { return -1; } }
/** * Creates a "header" string describing the current resultsets. * * @param comparisonColumn a value of type 'int' * @return a value of type 'String' */ @Override public String header(int comparisonColumn) { if (!m_ResultsetsValid) { try { prepareData(); } catch (Exception ex) { ex.printStackTrace(); return ex.getMessage(); } } initResultMatrix(); m_ResultMatrix.addHeader("Tester", getClass().getName() + " " + Utils.joinOptions(getOptions())); m_ResultMatrix.addHeader("Analysing", m_Instances.attribute(comparisonColumn).name()); m_ResultMatrix.addHeader("Datasets", Integer.toString(getNumDatasets())); m_ResultMatrix .addHeader("Resultsets", Integer.toString(getNumResultsets())); m_ResultMatrix.addHeader("Confidence", getSignificanceLevel() + " (two tailed)"); m_ResultMatrix.addHeader("Sorted by", getSortColumnName()); m_ResultMatrix.addHeader("Date", (new SimpleDateFormat()).format(new Date())); return m_ResultMatrix.toStringHeader() + "\n"; }
/** * removes the stored data but retains the dimensions of the matrix. */ public void clear() { super.clear(); LEFT_PARENTHESES = "["; RIGHT_PARENTHESES = "]"; }
matrix.addHeader("header1", "value1"); matrix.addHeader("header2", "value2"); matrix.addHeader("header2", "value3"); for (i = 0; i < matrix.getRowCount(); i++) { for (n = 0; n < matrix.getColCount(); n++) { matrix.setMean(n, i, (i+1)*n); matrix.setStdDev(n, i, ((double) (i+1)*n) / 100); if (i == n) { if (i % 2 == 1) matrix.setSignificance(n, i, SIGNIFICANCE_WIN); else matrix.setSignificance(n, i, SIGNIFICANCE_LOSS); System.out.println("\n\n--> " + matrix.getDisplayName()); System.out.println(matrix.toStringHeader() + "\n"); System.out.println(matrix.toStringMatrix() + "\n"); System.out.println(matrix.toStringKey()); matrix.setShowStdDev(true); System.out.println(matrix.toStringMatrix()); matrix.setPrintColNames(false); System.out.println(matrix.toStringMatrix()); matrix.setColHidden(1, true); System.out.println(matrix.toStringMatrix());
rows = getVisibleRowCount(); if (getShowAverage()) { rows++; cols = getVisibleColCount(); if (getShowStdDev()) { cols = cols * 3; // mean + stddev + sign. } else { result[0][0] = trimString("Dataset", getRowNameWidth()); x = 1; for (ii = 0; ii < getColCount(); ii++) { i = getDisplayCol(ii); if (getColHidden(i)) { continue; result[0][x] = trimString(removeFilterName(getColName(i)), getColNameWidth()); x++; if (getShowStdDev()) { result[0][x] = ""; x++; for (ii = 0; ii < getRowCount(); ii++) { i = getDisplayRow(ii); if (!getRowHidden(i)) { result[y][0] = trimString(removeFilterName(getRowName(i)), getRowNameWidth());
m_ResultMatrix.setRowOrder(m_SortOrder); m_ResultMatrix.setColOrder(m_ColOrder); m_ResultMatrix.setMeanWidth(maxWidthMean); m_ResultMatrix.setStdDevWidth(maxWidthStdDev); m_ResultMatrix.setSignificanceWidth(1); for (int i = 0; i < m_ResultMatrix.getColCount(); i++) { if ((i == baseResultset) && (m_ResultMatrix.getColHidden(i))) { m_ResultMatrix.setColHidden(i, false); System.err.println("Note: test base was hidden - set visible!"); m_ResultMatrix.setRowName(i, templateString(m_DatasetSpecifiers.specifier(i))); m_ResultMatrix.setCount(i, pairedStats.count); m_ResultMatrix.setMean(j, i, pairedStats.yStats.mean); m_ResultMatrix.setStdDev(j, i, pairedStats.yStats.stdDev); m_ResultMatrix.setSignificance(j, i, ResultMatrix.SIGNIFICANCE_WIN); } else if (pairedStats.differencesSignificance > 0) { m_ResultMatrix .setSignificance(j, i, ResultMatrix.SIGNIFICANCE_LOSS); } else { m_ResultMatrix.setSignificance(j, i, ResultMatrix.SIGNIFICANCE_TIE); result.append(m_ResultMatrix.toStringMatrix()); } catch (Exception e) {