예제 #1
0
파일: Average.java 프로젝트: avasekova/adml
  private static void recomputeTrainTestSets(TrainAndTestReport r) { // TODO a nicer way? :)
    if (r instanceof TrainAndTestReportCrisp) {
      TrainAndTestReportCrisp rep = (TrainAndTestReportCrisp) r;
      double[] newFittedValues =
          Arrays.copyOfRange(rep.getFittedValues(), 0, rep.getNumTrainingEntries());
      double[] newForecastValsTest =
          Arrays.copyOfRange(
              rep.getFittedValues(), rep.getNumTrainingEntries(), rep.getFittedValues().length);
      rep.setFittedValues(newFittedValues);
      rep.setForecastValuesTest(newForecastValsTest);
      double[] newRealTrain =
          Arrays.copyOfRange(rep.getRealOutputsTrain(), 0, rep.getNumTrainingEntries());
      double[] newRealTest =
          Arrays.copyOfRange(
              rep.getRealOutputsTrain(),
              rep.getNumTrainingEntries(),
              rep.getRealOutputsTrain().length);
      rep.setRealOutputsTrain(newRealTrain);
      rep.setRealOutputsTest(newRealTest);
      rep.setErrorMeasures(
          ErrorMeasuresUtils.computeAllErrorMeasuresCrisp(
              Utils.arrayToList(newRealTrain),
              Utils.arrayToList(newRealTest),
              Utils.arrayToList(newFittedValues),
              Utils.arrayToList(newForecastValsTest),
              0)); // TODO I hope the 0 is not a problem
    } else if (r instanceof TrainAndTestReportInterval) {
      TrainAndTestReportInterval rep = (TrainAndTestReportInterval) r;
      List<Interval> newFittedValues =
          new ArrayList<>(rep.getFittedValues().subList(0, rep.getNumTrainingEntries()));
      List<Interval> newForecastValsTest =
          new ArrayList<>(
              rep.getFittedValues()
                  .subList(rep.getNumTrainingEntries(), rep.getFittedValues().size()));
      rep.setFittedValues(newFittedValues);
      rep.setForecastValuesTest(newForecastValsTest);

      List<Interval> realVals =
          Utils.zipLowerUpperToIntervals(rep.getRealValuesLowers(), rep.getRealValuesUppers());
      List<Interval> realValsTrain =
          new ArrayList<>(realVals.subList(0, rep.getNumTrainingEntries()));
      List<Interval> realValsTest =
          new ArrayList<>(realVals.subList(rep.getNumTrainingEntries(), realVals.size()));

      // TODO somehow add the actual distance and seasonality from params
      rep.setErrorMeasures(
          ErrorMeasuresUtils.computeAllErrorMeasuresInterval(
              realValsTrain,
              realValsTest,
              newFittedValues,
              newForecastValsTest,
              new WeightedEuclideanDistance(0.5),
              0));
    }
  }
예제 #2
0
파일: UserApp.java 프로젝트: bluemir/hive
 /*
  * 신규 가입 사용자 생성
  */
 private static User createNewUser(User user) {
   RandomNumberGenerator rng = new SecureRandomNumberGenerator();
   user.passwordSalt = Arrays.toString(rng.nextBytes().getBytes());
   user.password = hashedPassword(user.password, user.passwordSalt);
   User.create(user);
   if (isUseSignUpConfirm()) {
     user.changeState(UserState.LOCKED);
   } else {
     user.changeState(UserState.ACTIVE);
   }
   Email.deleteOtherInvalidEmails(user.email);
   return user;
 }
예제 #3
0
  public Equals(String input, Map vars) {
    LispReader lr = new LispReader(new StringReader(input));
    String t = lr.next(); // read type
    if (!t.equals("=")) {
      System.err.println("= not found in Equals constructor");
      System.exit(-1);
    }

    left = Exp.makeExp(lr.next(), vars);
    right = Exp.makeExp(lr.next(), vars);

    if (!wellTyped()) {
      System.out.println("MISTYPED in Equals.java: " + this);
    }

    addToNameMap(Arrays.asList(left, right));
  }
예제 #4
0
 public List<Exp> getExp() {
   return Arrays.asList(left, right);
 }