Package weka.classifiers.bayes.net.estimate

Examples of weka.classifiers.bayes.net.estimate.SimpleEstimator


        BayesNetEstimator.class,
        estimatorName,
        Utils.partitionOptions(options)));
    }
    else {
      setEstimator(new SimpleEstimator());
    }

    Utils.checkForRemainingOptions(options);
  } // setOptions
View Full Code Here


        BayesNetEstimator.class,
        estimatorName,
        Utils.partitionOptions(options)));
    }
    else {
      setEstimator(new SimpleEstimator());
    }

    Utils.checkForRemainingOptions(options);
  } // setOptions
View Full Code Here

        BayesNetEstimator.class,
        estimatorName,
        Utils.partitionOptions(options)));
    }
    else {
      setEstimator(new SimpleEstimator());
    }

    Utils.checkForRemainingOptions(options);
  } // setOptions
View Full Code Here

                                Classifier yBN = new BayesNet();
                    K2 yK2 = new K2();
                    yK2.setMaxNrOfParents(1);
                    yK2.setInitAsNaiveBayes(true);
                    SimpleEstimator ySE = new SimpleEstimator();
    //                ySE.setAlpha(5);
                    ((BayesNet) yBN).setSearchAlgorithm(yK2);
                    ((BayesNet) yBN).setEstimator(ySE);


            for (int numToRem_counter = 0; numToRem_counter<numToRem.length;numToRem_counter++){
                for (int iteration_counter = 0; iteration_counter < removeIterations; iteration_counter++){

                    Instances learnPostRandRemove = new Instances(learnPreRandRemove);
//                    Instances holdPostRandRemove = new Instances(holdPreRandRemove);

                     Random rnd = new Random(1+numToRem_counter*10000+iteration_counter*10);
//                     StringBuilder remString = new StringBuilder("");


                     for (int rmv_counter = 0 ; rmv_counter < numToRem[numToRem_counter]; rmv_counter++){

                        String theInt = String.valueOf(1+rnd.nextInt(learnPreRandRemove.numAttributes()-1-rmv_counter));
                        Remove rmv = new Remove();
//                        System.out.println(1+numToRem_counter*10000+iteration_counter*10);
//                        System.out.println(theInt);
//                        remString.append(theInt).append(";");
                        rmv.setAttributeIndices(theInt);

                        try{
                            rmv.setInputFormat(learnPostRandRemove);
                            learnPostRandRemove = rmv.useFilter(learnPostRandRemove, rmv);
//                            holdPostRandRemove = rmv.useFilter(holdPostRandRemove, rmv);
                        } catch (Exception ex) {System.out.println(ex.toString());}
                    } // rmv_counter

                     // now the postRandRemove instances are configured



                    Classifier yBNcopy = Classifier.makeCopy(yBN);

                    Evaluation evPostRand = new Evaluation(learnPostRandRemove);
                    evPostRand.crossValidateModel(yBNcopy, learnPostRandRemove,Math.min(CVfoldNum,learn.numInstances()),new Random(winningNaiveRemove));

                    accPostRandRemove[numToRem_counter][iteration_counter] = evPostRand.pctCorrect();
                    rocPostRandRemove[numToRem_counter][iteration_counter] = evPostRand.weightedAreaUnderROC();
//                    if ((numToRem_counter % 100)==0){System.out.print(numToRem_counter);System.out.println("RandomRemovalLoop: ".concat(String.valueOf(evPostRand.weightedAreaUnderROC())));}
                }
            }

            //pick a winner

            wrep.BGS_removes_ROC_HI_LO_AVG = new double[3][numCats];

              for (int numToRem_counter = 0; numToRem_counter<numToRem.length;numToRem_counter++){
                  Arrays.sort(rocPostRandRemove[numToRem_counter]);

                  wrep.BGS_removes_ROC_HI_LO_AVG[0][numToRem_counter] = rocPostRandRemove[numToRem_counter][rocPostRandRemove[numToRem_counter].length-1];
                  wrep.BGS_removes_ROC_HI_LO_AVG[1][numToRem_counter] = rocPostRandRemove[numToRem_counter][0];
                  wrep.BGS_removes_ROC_HI_LO_AVG[2][numToRem_counter] = rocPostRandRemove[numToRem_counter][Math.round((float) Math.ceil((rocPostRandRemove[numToRem_counter].length-1)/2))];
              }


        int[] postRandWinnerArray = new int[numCats];
        for (int numToRem_counter = 0; numToRem_counter<numToRem.length;numToRem_counter++){
            postRandWinnerArray[numToRem_counter] = pickWinner(accPostRandRemove[numToRem_counter], rocPostRandRemove[numToRem_counter]);
        }

        // TODO: make a chart here.



        double[] accWinners = new double[numCats];
        double[] rocWinners = new double[numCats];
        for (int numToRem_counter = 0; numToRem_counter<numToRem.length;numToRem_counter++){
            accWinners[numToRem_counter] = accPostRandRemove[numToRem_counter][postRandWinnerArray[numToRem_counter]];
            rocWinners[numToRem_counter] = rocPostRandRemove[numToRem_counter][postRandWinnerArray[numToRem_counter]];
        }





        int winningPostRandRemove = pickWinner(accWinners, rocWinners);

            double[] accFinalRound = new double[removeIterations*10];
            double[] rocFinalRound = new double[removeIterations*10];



            double accFinal = -1;
            double rocFinal = -1;


                    Classifier zBN = new BayesNet();
                    K2 zK2 = new K2();
                    zK2.setMaxNrOfParents(1);
                    zK2.setInitAsNaiveBayes(true);
                    SimpleEstimator zSE = new SimpleEstimator();
    //                ySE.setAlpha(5);
                    ((BayesNet) zBN).setSearchAlgorithm(zK2);
                    ((BayesNet) zBN).setEstimator(zSE);

                for (int iteration_counter = 0; iteration_counter < removeIterations; iteration_counter++){
View Full Code Here

TOP

Related Classes of weka.classifiers.bayes.net.estimate.SimpleEstimator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.