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