Package weka.core

Examples of weka.core.Instance


      throw new IllegalStateException(e.toString() + "\n" + actor + " " + props.getRound() + ": " + instance.toString(), e);
    }
  }

  public Triple<Double, Double, Double> getFoldCallRaiseProbabilities(PlayerId actor, Propositionalizer props) {
    Instance instance;
    boolean preflop = "preflop".equals(props.getRound());
    if (preflop) {
      instance = getPreFoldCallRaiseInstance(actor, props);
    } else {
      instance = getPostFoldCallRaiseInstance(actor, props);
    }
    try {
      double probFold;
      if (preflop) {
        probFold = preFoldModel.classifyInstance(instance);
      } else {
        probFold = postFoldModel.classifyInstance(instance);
      }
      probFold = Math.min(1, Math.max(0, probFold));

      double probCall;
      if (preflop) {
        probCall = preCallModel.classifyInstance(instance);
      } else {
        probCall = postCallModel.classifyInstance(instance);
      }
      probCall = Math.min(1, Math.max(0, probCall));

      double probRaise;
      if (preflop) {
        probRaise = preRaiseModel.classifyInstance(instance);
      } else {
        probRaise = postRaiseModel.classifyInstance(instance);
      }
      probRaise = Math.min(1, Math.max(0, probRaise));

      double sum = probFold + probCall + probRaise;
      if (Double.isNaN(sum) || sum == 0 || Double.isInfinite(sum)) {
        throw new IllegalStateException("Bad probabilities: " + probFold + " (probFold), " + probCall + " (probCall), " + probRaise + " (probRaise)");
      }
      Triple<Double, Double, Double> result = new Triple<Double, Double, Double>(probFold / sum, probCall / sum, probRaise / sum);
      if (logger.isTraceEnabled()) {
        logger.trace(instance + ": " + result);
      }
      return result;
    } catch (Exception e) {
      throw new IllegalStateException(e.toString() + "\n" + actor + " " + props.getRound() + ": " + instance.toString(), e);
    }
  }
View Full Code Here


      throw new IllegalStateException(e.toString() + "\n" + actor + " " + props.getRound() + ": " + instance.toString(), e);
    }
  }

  public double[] getShowdownProbabilities(PlayerId actor, Propositionalizer props) {
    Instance instance = getShowdownInstance(actor, props);
    try {
      double[] prob = {
          Math.min(1,Math.max(0, showdown0Model.classifyInstance(instance))),
          Math.min(1,Math.max(0, showdown1Model.classifyInstance(instance))),
          Math.min(1,Math.max(0, showdown2Model.classifyInstance(instance))),
          Math.min(1,Math.max(0, showdown3Model.classifyInstance(instance))),
          Math.min(1,Math.max(0, showdown4Model.classifyInstance(instance))),
          Math.min(1,Math.max(0, showdown5Model.classifyInstance(instance))),
      };
      if (logger.isTraceEnabled()) {
        logger.trace(instance + ": " + prob);
      }
      return prob;
    } catch (Exception e) {
      throw new IllegalStateException(instance.toString(), e);
    }
  }
View Full Code Here


 
  public Instance getUnclassifiedInstance(Propositionalizer prop, Object actor) {
    PlayerData p = prop.getPlayers().get(actor);
    Instance instance = new Instance(length);
   
    instance.setDataset(dataset);
   
    instance.setValue(0, prop.getRoundCompletion());
    instance.setValue(1, prop.getPlayersActed());
    instance.setValue(2, prop.getPlayersToAct());
    instance.setValue(3, p.getGameCount());
    instance.setValue(4, prop.getTableGameStats().getNbRoundActions(prop));
    // Amounts
    instance.setValue(5, prop.getRelativePotSize());
    instance.setValue(6, p.getRelativeStack());
    // Player count
    instance.setValue(7, prop.getNbSeatedPlayers());
    instance.setValue(8, prop.getNbActivePlayers());
    instance.setValue(9, prop.getActivePlayerRatio());
    // Global player frequencies
    instance.setValue(10, p.getGlobalStats().getBetFrequency(4));
    // Per-round player frequencies
    instance.setValue(11, p.getGlobalStats().getRoundBetFrequency(prop,4));
    // PT Stats
    instance.setValue(12, p.getVPIP(4));
    instance.setValue(13, p.getPFR(4));
    instance.setValue(14, p.getGlobalStats().getAF(5));
    instance.setValue(15, p.getGlobalStats().getAFq(5));
    instance.setValue(16, (float)Math.log(p.getGlobalStats().getAFAmount(5)));
    instance.setValue(17, p.getWtSD(4));
    // Table PT stat averages
    instance.setValue(18, prop.getAverageVPIP(p,4));
    instance.setValue(19, prop.getAveragePFR(p,4));
    instance.setValue(20, prop.getAverageAF(p,5));
    instance.setValue(21, prop.getAverageAFq(p,5));
    instance.setValue(22, prop.getAverageAFAmount(p,5));
    instance.setValue(23, prop.getAverageWtSD(p,4));
    return instance;
  }
View Full Code Here

  }


  public Instance getUnclassifiedInstance(Propositionalizer prop, Object actor) {
    PlayerData p = prop.getPlayers().get(actor);
    Instance instance = new Instance(length);

    instance.setDataset(dataset);

    instance.setValue(0, prop.getRoundCompletion());
    instance.setValue(1, prop.getPlayersActed());
    instance.setValue(2, prop.getPlayersToAct());
    instance.setValue(3, prop.getRound());
    instance.setValue(4, p.getGameCount());
    instance.setValue(5, prop.getTableGameStats().getNbRoundActions(prop));
    // Amounts
    instance.setValue(6, prop.getRelativePotSize());
    instance.setValue(7, p.getRelativeStack());
    instance.setValue(8, (float)Math.log(p.getRelativeDeficit(prop)));
    instance.setValue(9, p.getPotOdds(prop));
    instance.setValue(10, (float)Math.log(prop.getRelativeMaxBet()));
    // Player count
    instance.setValue(11, prop.getNbSeatedPlayers());
    instance.setValue(12, prop.getNbActivePlayers());
    instance.setValue(13, prop.getActivePlayerRatio());
    // Global player frequencies
    // Global player frequencies
    instance.setValue(14, p.getGlobalStats().getFoldFrequency(4));
    instance.setValue(15, p.getGlobalStats().getCallFrequency(4));
    instance.setValue(16, p.getGlobalStats().getRaiseFrequency(4));
    // Per-round player frequencies
    instance.setValue(17, p.getGlobalStats().getRoundFoldFrequency(prop,4));
    instance.setValue(18, p.getGlobalStats().getRoundCallFrequency(prop,4));
    instance.setValue(19, p.getGlobalStats().getRoundRaiseFrequency(prop,4));
    // Game betting behaviour
    instance.setValue(20, p.isComitted()+"");
    instance.setValue(21, prop.getTableGameStats().getNbBetsRaises());
    instance.setValue(22, p.getGameStats().getNbBetsRaises());
    instance.setValue(23, p.getGameStats().getNbRoundBetsRaises(prop));
    instance.setValue(24, prop.rel(p.getGameStats().getNbBetsRaises(),prop.getTableGameStats().getNbBetsRaises()));
    instance.setValue(25, (float)Math.log1p(p.getGameStats().getTotalBetRaiseAmount()));
    instance.setValue(26, prop.rel(p.getGameStats().getTotalBetRaiseAmount(),prop.getTableGameStats().getTotalBetRaiseAmount()));
    instance.setValue(27, p.isLastActionWasRaise()+"");
    // PT Stats
    instance.setValue(28, p.getVPIP(4));
    instance.setValue(29, p.getPFR(4));
    instance.setValue(30, p.getGlobalStats().getAF(5));
    instance.setValue(31, p.getGlobalStats().getAFq(5));
    instance.setValue(32, (float)Math.log(p.getGlobalStats().getAFAmount(5)));
    instance.setValue(33, p.getWtSD(4));
    // Table PT stat averages
    instance.setValue(34, prop.getAverageVPIP(p,4));
    instance.setValue(35, prop.getAveragePFR(p,4));
    instance.setValue(36, prop.getAverageAF(p,5));
    instance.setValue(37, prop.getAverageAFq(p,5));
    instance.setValue(38, prop.getAverageAFAmount(p,5));
    instance.setValue(39, prop.getAverageWtSD(p,4));
    return instance;
  }
View Full Code Here

  }

  public abstract Instance getUnclassifiedInstance(Propositionalizer prop, Object actorId);

  public void addClassifiedInstance(Propositionalizer prop, Object actorId, Object[] targets){
    Instance instance = getClassifiedInstance(prop, actorId, targets);
    dataset.add(instance);
  }
View Full Code Here

    dataset.add(instance);
  }

  public Instance getClassifiedInstance(Propositionalizer prop,
      Object actorId, Object[] targets) {
    Instance instance = getUnclassifiedInstance(prop, actorId);
    for(int i=0; i<targets.length;i++){
      //dirty, blame weka
      if(targets[i] instanceof Number){
        instance.setValue(length-targets.length+i, ((Number)targets[i]).doubleValue());
      }else{
        instance.setValue(length-targets.length+i, (String)targets[i]);
      }
    }
    return instance;
  }
View Full Code Here



  public Instance getUnclassifiedInstance(Propositionalizer prop, Object actor) {
    PlayerData p = prop.getPlayers().get(actor);
    Instance instance = new Instance(length);
    if (p==null) p = new PlayerData(actor);
    instance.setDataset(dataset);

    instance.setValue(0, prop.getRoundCompletion());
    instance.setValue(1, prop.getPlayersActed());
    instance.setValue(2, prop.getPlayersToAct());
    instance.setValue(3, p.getGameCount());
    instance.setValue(4, prop.isSomebodyActedThisRound()+"");
    instance.setValue(5, prop.getTableGameStats().getNbRoundActions(prop));
    // Amounts
    instance.setValue(6, prop.getRelativePotSize());
    instance.setValue(7, p.getRelativeStack());
    instance.setValue(8, (float)Math.log(p.getRelativeDeficit(prop)));
    instance.setValue(9, p.getPotOdds(prop));
    instance.setValue(10, (float)Math.log(prop.getRelativeMaxBet()));
    // Player count
    instance.setValue(11, prop.getNbSeatedPlayers());
    instance.setValue(12, prop.getNbActivePlayers());
    instance.setValue(13, prop.getActivePlayerRatio());
    // Global player frequencies
    instance.setValue(14, p.getGlobalStats().getFoldFrequency(4));
    instance.setValue(15, p.getGlobalStats().getCallFrequency(4));
    instance.setValue(16, p.getGlobalStats().getRaiseFrequency(4));
    // Per-round player frequencies
    instance.setValue(17, p.getGlobalStats().getRoundFoldFrequency(prop,4));
    instance.setValue(18, p.getGlobalStats().getRoundCallFrequency(prop,4));
    instance.setValue(19, p.getGlobalStats().getRoundRaiseFrequency(prop,4));
    // Game betting behaviour
    instance.setValue(20, p.isComitted()+"");
    instance.setValue(21, prop.getTableGameStats().getNbBetsRaises());
    instance.setValue(22, p.getGameStats().getNbBetsRaises());
    instance.setValue(23, prop.rel(p.getGameStats().getNbBetsRaises(),prop.getTableGameStats().getNbBetsRaises()));
    instance.setValue(24, (float)Math.log1p(p.getGameStats().getTotalBetRaiseAmount()));
    instance.setValue(25, prop.rel(p.getGameStats().getTotalBetRaiseAmount(),prop.getTableGameStats().getTotalBetRaiseAmount()));
    instance.setValue(26, p.isLastActionWasRaise()+"");
    // PT Stats
    instance.setValue(27, p.getVPIP(4));
    instance.setValue(28, p.getPFR(4));
    instance.setValue(29, p.getGlobalStats().getAF(5));
    instance.setValue(30, p.getGlobalStats().getAFq(5));
    instance.setValue(31, (float)Math.log(p.getGlobalStats().getAFAmount(5)));
    instance.setValue(32, p.getWtSD(4));
    // Table PT stat averages
    instance.setValue(33, prop.getAverageVPIP(p,4));
    instance.setValue(34, prop.getAveragePFR(p,4));
    instance.setValue(35, prop.getAverageAF(p,5));
    instance.setValue(36, prop.getAverageAFq(p,5));
    instance.setValue(37, prop.getAverageAFAmount(p,5));
    instance.setValue(38, prop.getAverageWtSD(p,4));
    return instance;
  }
View Full Code Here

    super(name, attributes, targets);
  }

  @Override
  public Instance getUnclassifiedInstance(Propositionalizer prop, Object actorId) {
    Instance instance = new Instance(length);
    instance.setDataset(dataset);
    instance.setValue(0, prop.getRound()+"");
    return instance;
  }
View Full Code Here

  }


  public Instance getUnclassifiedInstance(Propositionalizer prop, Object actor) {
    PlayerData p = prop.getPlayers().get(actor);
    Instance instance = new Instance(length);

    instance.setDataset(dataset);

    instance.setValue(0, prop.getRoundCompletion());
    instance.setValue(1, prop.getPlayersActed());
    instance.setValue(2, prop.getPlayersToAct());
    instance.setValue(3, prop.getRound()+"");
    instance.setValue(4, p.getGameCount());
    instance.setValue(5, prop.isSomebodyActedThisRound()+"");
    instance.setValue(6, prop.getTableGameStats().getNbRoundActions(prop));
    // Amounts
    instance.setValue(7, prop.getRelativePotSize());
    instance.setValue(8, p.getRelativeStack());
    // Player count
    instance.setValue(9, prop.getNbSeatedPlayers());
    instance.setValue(10, prop.getNbActivePlayers());
    instance.setValue(11, prop.getActivePlayerRatio());
    // Global player frequencies
    instance.setValue(12, p.getGlobalStats().getBetFrequency(4));
    // Per-round player frequencies
    instance.setValue(13, p.getGlobalStats().getRoundBetFrequency(prop,4));
    // Game betting behaviour
    instance.setValue(14, prop.getTableGameStats().getNbBetsRaises());
    instance.setValue(15, p.getGameStats().getNbBetsRaises());
    instance.setValue(16, prop.rel(p.getGameStats().getNbBetsRaises(),prop.getTableGameStats().getNbBetsRaises()));
    instance.setValue(17, (float)Math.log1p(p.getGameStats().getTotalBetRaiseAmount()));
    instance.setValue(18, prop.rel(p.getGameStats().getTotalBetRaiseAmount(),prop.getTableGameStats().getTotalBetRaiseAmount()));
    instance.setValue(19, p.isLastActionWasRaise()+"");
    // PT Stats
    instance.setValue(20, p.getVPIP(4));
    instance.setValue(21, p.getPFR(4));
    instance.setValue(22, p.getGlobalStats().getAF(5));
    instance.setValue(23, p.getGlobalStats().getAFq(5));
    instance.setValue(24, (float)Math.log(p.getGlobalStats().getAFAmount(5)));
    instance.setValue(25, p.getWtSD(4));
    // Table PT stat averages
    instance.setValue(26, prop.getAverageVPIP(p,4));
    instance.setValue(27, prop.getAveragePFR(p,4));
    instance.setValue(28, prop.getAverageAF(p,5));
    instance.setValue(29, prop.getAverageAFq(p,5));
    instance.setValue(30, prop.getAverageAFAmount(p,5));
    instance.setValue(31, prop.getAverageWtSD(p,4));
    return instance;
  }
View Full Code Here

    super(name, attributes, targets);
  }

  public Instance getUnclassifiedInstance(Propositionalizer prop, Object actor) {
    PlayerData p = prop.getPlayers().get(actor);
    Instance instance = new Instance(length);
   
    instance.setDataset(dataset);

    instance.setValue(0, p.getGameCount());
    // Amounts
    instance.setValue(1, prop.getRelativePotSize());
    instance.setValue(2, (float)Math.log(prop.getRelativePotSize()));
    instance.setValue(3, p.getRelativeStack());
    instance.setValue(4, (float)Math.log1p(p.getRelativeStack()));
    // Player count
    instance.setValue(5, prop.getNbSeatedPlayers());
    instance.setValue(6, prop.getNbActivePlayers());
    instance.setValue(7, prop.getActivePlayerRatio());
    // Global player frequencies
    instance.setValue(8, p.getGlobalStats().getBetFrequency(4));
    instance.setValue(9, p.getGlobalStats().getFoldFrequency(4));
    instance.setValue(10, p.getGlobalStats().getCallFrequency(4));
    instance.setValue(11, p.getGlobalStats().getRaiseFrequency(4));
    //BetRaise counts
    instance.setValue(12, prop.getTableGameStats().getNbBetsRaises());
    instance.setValue(13, p.getGameStats().getNbBetsRaises());
    instance.setValue(14, p.getGameStats().getNbBetsRaisesPreFlop());
    instance.setValue(15, p.getGameStats().getNbBetsRaisesPostFlop());
    instance.setValue(16, p.getGameStats().getNbBetsRaisesFlop());
    instance.setValue(17, p.getGameStats().getNbBetsRaisesTurn());
    instance.setValue(18, p.getGameStats().getNbBetsRaisesRiver());
    //BetRaise amount
    instance.setValue(19, (float)prop.getTableGameStats().getTotalBetRaiseAmount());
    instance.setValue(20, (float)p.getGameStats().getTotalBetRaiseAmount());
    instance.setValue(21, (float)p.getGameStats().getBetRaiseAmountPreFlop());
    instance.setValue(22, (float)p.getGameStats().getBetRaiseAmountPostFlop());
    instance.setValue(23, (float)p.getGameStats().getBetRaiseAmountFlop());
    instance.setValue(24, (float)p.getGameStats().getBetRaiseAmountTurn());
    instance.setValue(25, (float)p.getGameStats().getBetRaiseAmountRiver());
    //Bet amount
    instance.setValue(26, (float)prop.getTableGameStats().getTotalBetAmount());
    instance.setValue(27, (float)p.getGameStats().getTotalBetAmount());
    instance.setValue(28, (float)p.getGameStats().getBetAmountPreFlop());
    instance.setValue(29, (float)p.getGameStats().getBetAmountPostFlop());
    instance.setValue(30, (float)p.getGameStats().getBetAmountFlop());
    instance.setValue(31, (float)p.getGameStats().getBetAmountTurn());
    instance.setValue(32, (float)p.getGameStats().getBetAmountRiver());
    //Raise amount
    instance.setValue(33, (float)prop.getTableGameStats().getTotalRaiseAmount());
    instance.setValue(34, (float)p.getGameStats().getTotalRaiseAmount());
    instance.setValue(35, (float)p.getGameStats().getRaiseAmountPreFlop());
    instance.setValue(36, (float)p.getGameStats().getRaiseAmountPostFlop());
    instance.setValue(37, (float)p.getGameStats().getRaiseAmountFlop());
    instance.setValue(38, (float)p.getGameStats().getRaiseAmountTurn());
    instance.setValue(39, (float)p.getGameStats().getRaiseAmountRiver());
    // Relative BetRaise counts
    instance.setValue(40, prop.rel(p.getGameStats().getNbBetsRaises(),prop.getTableGameStats().getNbBetsRaises()));
    instance.setValue(41, prop.rel(p.getGameStats().getNbBetsRaisesPreFlop(),prop.getTableGameStats().getNbBetsRaisesPreFlop()));
    instance.setValue(42, prop.rel(p.getGameStats().getNbBetsRaisesPostFlop(),prop.getTableGameStats().getNbBetsRaisesPostFlop()));
    instance.setValue(43, prop.rel(p.getGameStats().getNbBetsRaisesFlop(),prop.getTableGameStats().getNbBetsRaisesFlop()));
    instance.setValue(44, prop.rel(p.getGameStats().getNbBetsRaisesTurn(),prop.getTableGameStats().getNbBetsRaisesTurn()));
    instance.setValue(45, prop.rel(p.getGameStats().getNbBetsRaisesRiver(),prop.getTableGameStats().getNbBetsRaisesRiver()));
    // Relative BetRaise amounts
    instance.setValue(46, prop.rel(p.getGameStats().getTotalBetRaiseAmount(),prop.getTableGameStats().getTotalBetRaiseAmount()));
    instance.setValue(47, prop.rel(p.getGameStats().getBetRaiseAmountPreFlop(),prop.getTableGameStats().getBetRaiseAmountPreFlop()));
    instance.setValue(48, prop.rel(p.getGameStats().getBetRaiseAmountPostFlop(),prop.getTableGameStats().getBetRaiseAmountPostFlop()));
    instance.setValue(49, prop.rel(p.getGameStats().getBetRaiseAmountFlop(),prop.getTableGameStats().getBetRaiseAmountFlop()));
    instance.setValue(50, prop.rel(p.getGameStats().getBetRaiseAmountTurn(),prop.getTableGameStats().getBetRaiseAmountTurn()));
    instance.setValue(51, prop.rel(p.getGameStats().getBetRaiseAmountRiver(),prop.getTableGameStats().getBetRaiseAmountRiver()));
    //Table BetRaise counts
    instance.setValue(52, prop.getTableGameStats().getNbBetsRaisesPreFlop());
    instance.setValue(53, prop.getTableGameStats().getNbBetsRaisesPostFlop());
    instance.setValue(54, prop.getTableGameStats().getNbBetsRaisesFlop());
    instance.setValue(55, prop.getTableGameStats().getNbBetsRaisesTurn());
    instance.setValue(56, prop.getTableGameStats().getNbBetsRaisesRiver());
    //Table BetRaise amount
    instance.setValue(57, (float)prop.getTableGameStats().getBetRaiseAmountPreFlop());
    instance.setValue(58, (float)prop.getTableGameStats().getBetRaiseAmountPostFlop());
    instance.setValue(59, (float)prop.getTableGameStats().getBetRaiseAmountFlop());
    instance.setValue(60, (float)prop.getTableGameStats().getBetRaiseAmountTurn());
    instance.setValue(61, (float)prop.getTableGameStats().getBetRaiseAmountRiver());
    // Other
    instance.setValue(62, p.isLastActionWasRaise()+"");
    // PT Stats
    instance.setValue(63, p.getVPIP(4));
    instance.setValue(64, p.getPFR(4));
    instance.setValue(65, p.getGlobalStats().getAF(5));
    instance.setValue(66, p.getGlobalStats().getAFq(5));
    instance.setValue(67, (float)Math.log(p.getGlobalStats().getAFAmount(5)));
    instance.setValue(68, p.getWtSD(4));
    // Table PT stat averages
    instance.setValue(69, prop.getAverageVPIP(p,4));
    instance.setValue(70, prop.getAveragePFR(p,4));
    instance.setValue(71, prop.getAverageAF(p,5));
    instance.setValue(72, prop.getAverageAFq(p,5));
    instance.setValue(73, prop.getAverageAFAmount(p,5));
    instance.setValue(74, prop.getAverageWtSD(p,4));
    return instance;
  }
View Full Code Here

TOP

Related Classes of weka.core.Instance

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.