@Test public void testComputeWeightedVote() { Prediction weightedPred=weightedVote.computeWeightedVote(); assertEquals(2.8947368416,weightedPred.getVote(0, 0), EPS); assertEquals(2,weightedPred.getVote(1, 0), EPS); assertEquals(3,weightedPred.getVote(2, 0), EPS); assertEquals(2.5000000008,weightedPred.getVote(3, 0), EPS); }
@Override public Prediction computeWeightedVote() { int n=votes.size(); if (n>0){ int numOutputs=outputAttributesCount.length; weights=new double[n][numOutputs]; weightedVote=new MultiLabelPrediction(numOutputs); double [] sumError= new double[numOutputs]; for (int o=0;o<numOutputs;o++) { for (int i=0; i<n; i++) { if(votes.get(i).hasVotesForAttribute(o) && errors.get(i)!=null){ weights[i][o]=1.0/(errors.get(i)[o]+EPS); sumError[o]+=weights[i][o]; } } for (int i=0; i<n; i++) { int numClasses=votes.get(i).numClasses(o); if(votes.get(i).hasVotesForAttribute(o)){ if(sumError[o]>0) weights[i][o]/=sumError[o]; else weights[i][o]=1.0/outputAttributesCount[o]; } for(int j=0; j<numClasses; j++){ weightedVote.setVote(o, j, weightedVote.getVote(o, j)+votes.get(i).getVote(o, j)*weights[i][o]); } } } } return weightedVote; }
InverseErrorWeightedVoteMultiLabel extends AbstractErrorWeightedVoteMultiLabel { @Override public Prediction computeWeightedVote() { int n=votes.size(); if (n>0){ int numOutputs=outputAttributesCount.length; weights=new double[n][numOutputs]; weightedVote=new MultiLabelPrediction(numOutputs); double [] sumError= new double[numOutputs]; for (int o=0;o<numOutputs;o++) { for (int i=0; i<n; i++) { if(votes.get(i).hasVotesForAttribute(o) && errors.get(i)!=null){ weights[i][o]=1.0/(errors.get(i)[o]+EPS); sumError[o]+=weights[i][o]; } } for (int i=0; i<n; i++) { int numClasses=votes.get(i).numClasses(o); if(votes.get(i).hasVotesForAttribute(o)){ if(sumError[o]>0) weights[i][o]/=sumError[o]; else weights[i][o]=1.0/outputAttributesCount[o]; } for(int j=0; j<numClasses; j++){ weightedVote.setVote(o, j, weightedVote.getVote(o, j)+votes.get(i).getVote(o, j)*weights[i][o]); } } } } return weightedVote; } }
InverseErrorWeightedVoteMultiLabel extends AbstractErrorWeightedVoteMultiLabel { @Override public Prediction computeWeightedVote() { int n=votes.size(); if (n>0){ int numOutputs=outputAttributesCount.length; weights=new double[n][numOutputs]; weightedVote=new MultiLabelPrediction(numOutputs); double [] sumError= new double[numOutputs]; for (int o=0;o<numOutputs;o++) { for (int i=0; i<n; i++) { if(votes.get(i).hasVotesForAttribute(o) && errors.get(i)!=null){ weights[i][o]=1.0/(errors.get(i)[o]+EPS); sumError[o]+=weights[i][o]; } } for (int i=0; i<n; i++) { int numClasses=votes.get(i).numClasses(o); if(votes.get(i).hasVotesForAttribute(o)){ if(sumError[o]>0) weights[i][o]/=sumError[o]; else weights[i][o]=1.0/outputAttributesCount[o]; } for(int j=0; j<numClasses; j++){ weightedVote.setVote(o, j, weightedVote.getVote(o, j)+votes.get(i).getVote(o, j)*weights[i][o]); } } } } return weightedVote; }  }
InverseErrorWeightedVoteMultiLabel extends AbstractErrorWeightedVoteMultiLabel { @Override public Prediction computeWeightedVote() { int n=votes.size(); if (n>0){ int numOutputs=outputAttributesCount.length; weights=new double[n][numOutputs]; weightedVote=new MultiLabelPrediction(numOutputs); double [] sumError= new double[numOutputs]; for (int o=0;o<numOutputs;o++) { for (int i=0; i<n; i++) { if(votes.get(i).hasVotesForAttribute(o) && errors.get(i)!=null){ weights[i][o]=1.0/(errors.get(i)[o]+EPS); sumError[o]+=weights[i][o]; } } for (int i=0; i<n; i++) { int numClasses=votes.get(i).numClasses(o); if(votes.get(i).hasVotesForAttribute(o)){ if(sumError[o]>0) weights[i][o]/=sumError[o]; else weights[i][o]=1.0/outputAttributesCount[o]; } for(int j=0; j<numClasses; j++){ weightedVote.setVote(o, j, weightedVote.getVote(o, j)+votes.get(i).getVote(o, j)*weights[i][o]); } } } } return weightedVote; }  @Override Prediction computeWeightedVote(); }
InverseErrorWeightedVoteMultiLabel extends AbstractErrorWeightedVoteMultiLabel { @Override public Prediction computeWeightedVote() { int n=votes.size(); if (n>0){ int numOutputs=outputAttributesCount.length; weights=new double[n][numOutputs]; weightedVote=new MultiLabelPrediction(numOutputs); double [] sumError= new double[numOutputs]; for (int o=0;o<numOutputs;o++) { for (int i=0; i<n; i++) { if(votes.get(i).hasVotesForAttribute(o) && errors.get(i)!=null){ weights[i][o]=1.0/(errors.get(i)[o]+EPS); sumError[o]+=weights[i][o]; } } for (int i=0; i<n; i++) { int numClasses=votes.get(i).numClasses(o); if(votes.get(i).hasVotesForAttribute(o)){ if(sumError[o]>0) weights[i][o]/=sumError[o]; else weights[i][o]=1.0/outputAttributesCount[o]; } for(int j=0; j<numClasses; j++){ weightedVote.setVote(o, j, weightedVote.getVote(o, j)+votes.get(i).getVote(o, j)*weights[i][o]); } } } } return weightedVote; }  @Override Prediction computeWeightedVote();  }