Package com.yahoo.labs.taxomo.learn

Examples of com.yahoo.labs.taxomo.learn.Candidate


      logger.info("Learning model for cluster " + clusterNum);

      // Clone initial candidate (so that it does not have a set
      // logProbability)
      Candidate initialCandidate = prototypeInitialCandidate.clone();

      // Initialize weight1 for model
      double weight1 = learnerMaxWeight1 != -1 ? learnerMaxWeight1 : 1.0;

      // Create and set-up learner
View Full Code Here


    // Load tree
    File taxoFile = new File(jsapResult.getString("taxonomy-file"));
    Taxonomy tree = new Taxonomy(taxoFile);

    // Build initial candidate
    Candidate initialCandidate;
    if (jsapResult.userSpecified("init-explicit")) {
      initialCandidate = new Candidate(tree, Util.split(jsapResult.getString("init-explicit")), null, null);

    } else if (jsapResult.userSpecified("init-all-level")) {
      initialCandidate = Candidate.createFixedLevelCandidate(tree, jsapResult.getInt("init-all-level"));

    } else if (jsapResult.getBoolean("init-all-leaves")) {
      initialCandidate = Candidate.createLeafCandidate(tree);

    } else {
      throw new IllegalArgumentException("Either --init-explicit, --init-all-leaves, or --init-all-level should be specified. See --help.");
    }
    logger.debug("Initial candidate is " + initialCandidate.toBriefString());

    // Set learning parameters
    Class<SearchStrategy> strategy = (Class<SearchStrategy>) Class.forName(SearchStrategy.class.getPackage().getName() + "." + jsapResult.getString("search-method"));
    logger.debug("Search strategy is " + strategy);
View Full Code Here

    // Compute minProbability
    logger.debug("Evaluating minimum probability");
    ArrayList<String> rootStateOnly = new ArrayList<String>(1);
    rootStateOnly.add(tree.getRootState().name());
    Candidate singleStateCandidate = new Candidate(tree, rootStateOnly, null, null);
    doSlowEvaluation(singleStateCandidate);
    minLogProbability = singleStateCandidate.getLogProbability();
    logger.debug("Minimum probability: " + minLogProbability);

    // Compute maxProbability
    logger.debug("Evaluating maximum probability");
    doSlowEvaluation(initialCandidate);
View Full Code Here

  @SuppressWarnings("boxing")
  void printReport(PrintWriter out) throws IOException {

    logger.info( "Preparing to write log file: re-sorting by experiment number");
    // Sort candidates by experiment number
    Candidate resultsSorted[] = results.keySet().toArray(new Candidate[] {});
    Arrays.sort(resultsSorted, new Comparator<Candidate>() {
      public int compare(Candidate arg0, Candidate arg1) {
        int it0 = results.get(arg0).intValue();
        int it1 = results.get(arg1).intValue();
        if (it0 < it1) {
View Full Code Here

 
  public Model getBestModel(int maxOutputStates) {
    logger.info( "Will score candidates by " + outputScorer );
   
    // Sort candidates by output scorer
    Candidate resultsSorted[] = results.keySet().toArray(new Candidate[] {});
    Arrays.sort(resultsSorted, (SearchStrategy)outputScorer);
   
    int minNumStatesReached = Integer.MAX_VALUE;
    for( int i=0; i<resultsSorted.length; i++ ) {
      int numStates = resultsSorted[i].getNumStates();
      if( (numStates>1) && (numStates < minNumStatesReached) ) {
        minNumStatesReached = numStates;
      }
    }
   
    int realisticMaxOutputStates = maxOutputStates;
    if( minNumStatesReached > maxOutputStates ) {
      logger.warn( "Could not find a model with " + maxOutputStates + " states or less" );
      logger.warn( "Apart from the model with one state (which is never returned!), all the other models had " + minNumStatesReached + " states or more" );
      realisticMaxOutputStates = minNumStatesReached;
    }
   
    // Try to find the best one
    Candidate winner = null;
    for( int i=0; i<resultsSorted.length; i++ ) {
      int numStates = resultsSorted[i].getNumStates();
      // The model with only 1 state is never returned
      if( (numStates>1) && (numStates <= realisticMaxOutputStates ) ) {
        winner = resultsSorted[i];
View Full Code Here

    }

    File inputFile = new File(jsapResult.getString("input-file"));
    File taxoFile = new File(jsapResult.getString("taxonomy-file"));
    Taxonomy tree = new Taxonomy(taxoFile);
    Candidate initialCandidate;

    if (jsapResult.userSpecified("init-explicit")) {
      initialCandidate = new Candidate(tree, Util.split(jsapResult.getString("init-explicit")), null, null);

    } else if (jsapResult.userSpecified("init-all-level")) {
      initialCandidate = Candidate.createFixedLevelCandidate(tree, jsapResult.getInt("init-all-level"));
     
    } else if (jsapResult.getBoolean("init-all-leaves")) {
      initialCandidate = Candidate.createLeafCandidate(tree);

    } else {
      throw new IllegalArgumentException("Either --init-explicit, --init-all-leaves, or --init-all-level should be specified. See --help.");
    }
    logger.debug("Initial candidate is " + initialCandidate.toBriefString());
   
    Class<SearchStrategy> strategy = (Class<SearchStrategy>) Class.forName(SearchStrategy.class.getPackage().getName() + "." + jsapResult.getString("search-method"));
    logger.debug("Search strategy is " + strategy );
   
    double weight1 = jsapResult.getDouble("search-method-weight-1");
View Full Code Here

TOP

Related Classes of com.yahoo.labs.taxomo.learn.Candidate

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.