double costVal; if (!(element instanceof Double)) { costVal = ((InstanceExpression) element).evaluate(inst); } else { costVal = ((Double) element).doubleValue();
factor = ((Double) element).doubleValue(); } else { factor = ((InstanceExpression) element).evaluate(inst);
factor = ((Double) element).doubleValue(); } else { factor = ((InstanceExpression) element).evaluate(inst);
double costVal; if (!(element instanceof Double)) { costVal = ((InstanceExpression) element).evaluate(inst); } else { costVal = ((Double) element).doubleValue();
/** * Gets the maximum cost for a particular class value. * * @param classVal the class value. * @return the maximum cost. * @exception Exception if cost matrix contains non-fixed costs */ public double getMaxCost(int classVal, Instance inst) throws Exception { if (!replaceStrings(inst.dataset())) { return getMaxCost(classVal); } double maxCost = Double.NEGATIVE_INFINITY; double cost; for (int i = 0; i < m_size; i++) { Object element = getCell(classVal, i); if (!(element instanceof Double)) { cost = ((InstanceExpression) element).evaluate(inst); } else { cost = ((Double) element).doubleValue(); } if (cost > maxCost) maxCost = cost; } return maxCost; }
/** * Gets the maximum cost for a particular class value. * * @param classVal the class value. * @return the maximum cost. * @exception Exception if cost matrix contains non-fixed costs */ public double getMaxCost(int classVal, Instance inst) throws Exception { if (!replaceStrings(inst.dataset())) { return getMaxCost(classVal); } double maxCost = Double.NEGATIVE_INFINITY; double cost; for (int i = 0; i < m_size; i++) { Object element = getCell(classVal, i); if (!(element instanceof Double)) { cost = ((InstanceExpression) element).evaluate(inst); } else { cost = ((Double) element).doubleValue(); } if (cost > maxCost) maxCost = cost; } return maxCost; }
/** * Return the value of a cell as a double. Computes the value for non-fixed * costs using the supplied Instance * * @param rowIndex the row * @param columnIndex the column * @return the value from a particular cell * @exception Exception if something goes wrong */ public final double getElement(int rowIndex, int columnIndex, Instance inst) throws Exception { if (m_matrix[rowIndex][columnIndex] instanceof Double) { return ((Double) m_matrix[rowIndex][columnIndex]).doubleValue(); } else if (m_matrix[rowIndex][columnIndex] instanceof String) { replaceStrings(inst.dataset()); } return ((InstanceExpression) m_matrix[rowIndex][columnIndex]) .evaluate(inst); }
/** * Return the value of a cell as a double. Computes the value for non-fixed * costs using the supplied Instance * * @param rowIndex the row * @param columnIndex the column * @return the value from a particular cell * @exception Exception if something goes wrong */ public final double getElement(int rowIndex, int columnIndex, Instance inst) throws Exception { if (m_matrix[rowIndex][columnIndex] instanceof Double) { return ((Double) m_matrix[rowIndex][columnIndex]).doubleValue(); } else if (m_matrix[rowIndex][columnIndex] instanceof String) { replaceStrings(inst.dataset()); } return ((InstanceExpression) m_matrix[rowIndex][columnIndex]) .evaluate(inst); }
private boolean replaceStrings(Instances dataset) throws Exception { boolean nonDouble = false; for (int i = 0; i < m_size; i++) { for (int j = 0; j < m_size; j++) { if (getCell(i, j) instanceof String) { setCell(i, j, new InstanceExpression((String) getCell(i, j), dataset)); nonDouble = true; } else if (getCell(i, j) instanceof InstanceExpression) { nonDouble = true; } } } return nonDouble; }
private boolean replaceStrings(Instances dataset) throws Exception { boolean nonDouble = false; for (int i = 0; i < m_size; i++) { for (int j = 0; j < m_size; j++) { if (getCell(i, j) instanceof String) { setCell(i, j, new InstanceExpression((String) getCell(i, j), dataset)); nonDouble = true; } else if (getCell(i, j) instanceof InstanceExpression) { nonDouble = true; } } } return nonDouble; }