001package es.ucm.fdi.gaia.jcolibri.method.revise.classification; 002 003 004import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase; 005import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCaseBase; 006import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRQuery; 007import es.ucm.fdi.gaia.jcolibri.extensions.classification.ClassificationSolution; 008import es.ucm.fdi.gaia.jcolibri.method.reuse.classification.KNNClassificationConfig; 009 010/** 011 * Interface that defines functions to decide if a query has been correctly classified 012 * or not and to assign a cost to incorrectly classified queries. 013 * 014 * @author Derek Bridge 015 * @author Lisa Cummins 016 * 16/05/07 017 */ 018public interface ClassificationOracle { 019 020 /** 021 * Checks if the predicted solution is the correct solution 022 * for the given test case. 023 * @param predictedSolution the predicted solution. 024 * @param testCase the test case (query and correct solution). 025 * @return true if the predicted solution is the correct solution 026 * for the given test case, false if not. 027 */ 028 public boolean isCorrectPrediction(ClassificationSolution predictedSolution, CBRCase testCase); 029 030 /** 031 * Checks if the predicted solution and the correct solution 032 * are the same. 033 * @param predictedSolution the predicted solution. 034 * @param correctSolution the correct solution. 035 * @return true if the predicted solution and the correct 036 * solution are the same, false if not. 037 */ 038 public boolean isCorrectPrediction(ClassificationSolution predictedSolution, ClassificationSolution correctSolution); 039 040 /** 041 * Checks if the query is correctly classified by the given case-base and 042 * similarity configuration. 043 * @param query the query to be tested. 044 * @param caseBase the case base to use to find the predicted solution. 045 * @param knnConfig the similarity configuration. 046 * @return true if the query is correctly classified by the given case-base and 047 * similarity configuration, fasle otherwise. 048 */ 049 public boolean isCorrectPrediction(CBRQuery query, CBRCaseBase caseBase, KNNClassificationConfig knnConfig); 050 051 /** 052 * Calculates the cost of the given solution as a prediction for the 053 * solution of the given case. 054 * @param predictedSolution the predicted solution. 055 * @param testCase the test case (query and correct solution). 056 * @return the cost of the prediction made. 057 */ 058 public double getPredictionCost(ClassificationSolution predictedSolution, CBRCase testCase); 059 060 /** 061 * Calculates the cost of the given test solution while bein compared 062 * to the given correct solution. 063 * @param predictedSolution the predicted solution. 064 * @param correctSolution the correct solution. 065 * @return the cost of the prediction made. 066 */ 067 public double getPredictionCost(ClassificationSolution predictedSolution, ClassificationSolution correctSolution); 068 069 /** 070 * Calculates the cost of the prediction made by the given case-base and 071 * similarity configuration for the solution of the query. 072 * @param query the query to be tested. 073 * @param caseBase the case base to use to find the predicted solution. 074 * @param knnConfig the similarity configuration. 075 * @return the cost of the prediction made. 076 */ 077 public double getPredictionCost(CBRQuery query, CBRCaseBase caseBase, KNNClassificationConfig knnConfig); 078}