@Override
    protected Status updateObservationAndClassifierWeights(Dataframe validationDataset, AssociativeArray observationWeights) {
        //calculate prediction error for this classifier
        double error = 0.0;
        for(Map.Entry<Integer, Record> e : validationDataset.entries()) {
            Integer rId = e.getKey();
            Record r = e.getValue();
            if(!r.getY().equals(r.getYPredicted())) {
                error+= TypeInference.toDouble(observationWeights.get(rId));
            }
        }
        
        ModelParameters modelParameters = knowledgeBase.getModelParameters();

        Status status;
        int c = modelParameters.getC();
        if((1.0-error)<=1.0/c) { //if accuracy is less than random
            status = Status.IGNORE; //do not include the classifier in our list
        }
        else {
            status = Status.NEXT; //continue training
            
            if(error==0.0) { //if the error is 0.0 stop, you can't make it bettter
                status = Status.STOP;
                error=1e-8;
            }
            
            List<Double> weakClassifierWeights = modelParameters.getWeakClassifierWeights();

            //add the new weak learner in the list of weights
            double weight = Math.log((1.0-error)/error)+Math.log(c-1.0);
            weakClassifierWeights.add(weight);

            //update the weights of observations
            for(Map.Entry<Integer, Record> e : validationDataset.entries()) {
                Integer rId = e.getKey();
                Record r = e.getValue();
                if(!r.getY().equals(r.getYPredicted())) {
                    Double value = TypeInference.toDouble(observationWeights.get(rId));
                    observationWeights.put(rId, value*Math.exp(weight)); //increase the weight for misclassified observations
                }
            }
            
            //normalize weights
            double normalizer = Descriptives.sum(new FlatDataCollection(observationWeights.values()));
            if(normalizer!=0.0) {
                for(Map.Entry<Object, Object> entry : observationWeights.entrySet()) {
                    Double value = TypeInference.toDouble(entry.getValue());
                    observationWeights.put(entry.getKey(), value/normalizer);
                }
            }
            
        }
        
        return status; 
    }
@ Override protected Status updateObservationAndClassifierWeights ( Dataframe validationDataset , AssociativeArray observationWeights ) { double error = 0.0 ; for ( Map . Entry < Integer , Record > e : validationDataset . entries ( ) ) { Integer rId = e . getKey ( ) ; Record r = e . getValue ( ) ; if ( ! r . getY ( ) . equals ( r . getYPredicted ( ) ) ) { error += TypeInference . toDouble ( observationWeights . get ( rId ) ) ; } } ModelParameters modelParameters = knowledgeBase . getModelParameters ( ) ; Status status ; int c = modelParameters . getC ( ) ; if ( ( 1.0 - error ) <= 1.0 / c ) { status = Status . IGNORE ; } else { status = Status . NEXT ; if ( error == 0.0 ) { status = Status . STOP ; error = 1e-8 ; } List < Double > weakClassifierWeights = modelParameters . getWeakClassifierWeights ( ) ; double weight = Math . log ( ( 1.0 - error ) / error ) + Math . log ( c - 1.0 ) ; weakClassifierWeights . add ( weight ) ; for ( Map . Entry < Integer , Record > e : validationDataset . entries ( ) ) { Integer rId = e . getKey ( ) ; Record r = e . getValue ( ) ; if ( ! r . getY ( ) . equals ( r . getYPredicted ( ) ) ) { Double value = TypeInference . toDouble ( observationWeights . get ( rId ) ) ; observationWeights . put ( rId , value * Math . exp ( weight ) ) ; } } double normalizer = Descriptives . sum ( new FlatDataCollection ( observationWeights . values ( ) ) ) ; if ( normalizer != 0.0 ) { for ( Map . Entry < Object , Object > entry : observationWeights . entrySet ( ) ) { Double value = TypeInference . toDouble ( entry . getValue ( ) ) ; observationWeights . put ( entry . getKey ( ) , value / normalizer ) ; } } } return status ; }
{@inheritDoc}