Examples of DoubleList


Examples of org.apache.commons.collections.primitives.DoubleList

   {
      Row result = new Row(metadata);

      int[] inOutIndexes = new int[2];
      int typeOfIndex = 0;
      DoubleList vector = input;

      for (ColumnInfo columnInfo : metadata.getColumns())
      {
         if (columnInfo.getVariableType() == VariableType.ID)
         {
            result.add(id);
            continue;
         }

         if (columnInfo.getVariableType() == VariableType.IN)
         {
            typeOfIndex = 0;
            vector = input;
         }
         else if (columnInfo.getVariableType() == VariableType.OUT)
         {
            typeOfIndex = 1;
            vector = output;
         }

         if (columnInfo.getDataType() == DataType.Number)
         {
            result.add(vector.get(inOutIndexes[typeOfIndex]++));
         }
         else if (columnInfo.getDataType() == DataType.Boolean)
         {
            result.add(vector.get(inOutIndexes[typeOfIndex]++) > 0);
         }
         else if (columnInfo.getDataType() == DataType.Category)
         {
            double maxElement = Integer.MIN_VALUE;
            int maxElementIndex = 0;

            final int elementsOfCategoryCount = columnInfo.getValuesOfCategory().size();
            for (
                    int i = inOutIndexes[typeOfIndex];
                    i < inOutIndexes[typeOfIndex] + elementsOfCategoryCount; ++i)
            {
               if (maxElement < vector.get(i))
               {
                  maxElement = vector.get(i);
                  maxElementIndex = i - inOutIndexes[typeOfIndex];
               }
            }
            inOutIndexes[typeOfIndex] += elementsOfCategoryCount;
View Full Code Here

Examples of org.apache.commons.collections.primitives.DoubleList

      List<List<Row>> dataClasses = new ArrayList<List<Row>>();

      for (int i = 0; i < data.size(); ++i)
      {
         Sample pair = data.get(i).createSample();
         DoubleList output = pair.getOutput();

         if (i == 0)
         {
            for (int k = 0; k < output.size(); ++k)
            {
               dataClasses.add(new ArrayList<Row>());
            }
         }

         for (int j = 0; j < output.size(); ++j)
         {
            if (output.get(j) == IN_CLASS_VALUE)
            {
               dataClasses.get(j).add(data.get(i));
               break;
            }
         }
View Full Code Here

Examples of org.apache.commons.collections.primitives.DoubleList

      return Math.sqrt(result);
   }

   public static DoubleList center(List<DoubleList> values)
   {
      DoubleList center = new ArrayDoubleList();

      final int componentsCount = values.get(0).size();
      for (int k = 0; k < componentsCount; ++k)
      {
         double sum = 0;
         for (int i = 0; i < values.size(); ++i)
         {
            sum += values.get(i).get(k);
         }

         center.add(sum / (double) values.size());
      }

      return center;
   }
View Full Code Here

Examples of org.apache.commons.collections.primitives.DoubleList

      return Math.round(d * c) / c;
   }

   public static DoubleList roundDoubleList(DoubleList list, int sign)
   {
      DoubleList result = new ArrayDoubleList(list.size());

      for (int i = 0; i < list.size(); ++i)
      {
         result.add(roundDouble(list.get(i), sign));
      }

      return result;
   }
View Full Code Here

Examples of org.apache.commons.collections.primitives.DoubleList

   public Sample createSample()
   {
      Comparable id = (Comparable) get(0);

      DoubleList input = new ArrayDoubleList();
      DoubleList output = new ArrayDoubleList();

      for (int i = 1; i < size(); ++i)
      {
         ColumnInfo columnInfo = metadata.getColumn(i);

         DoubleList dest = null;
         if (columnInfo.getVariableType() == VariableType.IN)
         {
            dest = input;
         }
         else if (columnInfo.getVariableType() == VariableType.OUT)
         {
            dest = output;
         }

         if (columnInfo.getDataType() == DataType.Number)
         {
            dest.add(getDouble(i));
         }
         else if (columnInfo.getDataType() == DataType.Category)
         {
            dest.addAll(extractZeroOneVector(columnInfo));
         }
         else if (columnInfo.getDataType() == DataType.Boolean)
         {
            dest.add(BooleanUtils.isTrue(getBoolean(i)) ? IN_CLASS_VALUE : OUT_OF_CLASS_VALUE);
         }
      }

      return new Sample(id, input, output);
   }
View Full Code Here

Examples of org.apache.commons.collections.primitives.DoubleList

   private DoubleList extractZeroOneVector(ColumnInfo columnInfo)
   {
      String element = getString(columnInfo.getIndex());

      SortedSet<String> valuesOfCategory = columnInfo.getValuesOfCategory();
      DoubleList zeroOneVector = new ArrayDoubleList();

      for (String value : valuesOfCategory)
      {
         zeroOneVector.add(ObjectUtils.equals(element, value) ? IN_CLASS_VALUE : OUT_OF_CLASS_VALUE);
      }

      return zeroOneVector;
   }
View Full Code Here

Examples of org.apache.commons.collections.primitives.DoubleList

      final List<ColumnInfo> outputColumns = metadata.resolveColumns(VariableType.OUT);

      // first pass - calc values ranges
      for (int i = 0; i < forecast.size(); ++i)
      {
         DoubleList output = networkKorecast.get(i).getOutput();

         for (ColumnInfo columnInfo : outputColumns)
         {
            Double currentMin = minValues.get(columnInfo);
            Double currentMax = maxValues.get(columnInfo);

            int firstIndex = metadata.getFirstIndexInTrainingDataset(columnInfo);
            int endIndex = metadata.getEndIndexInTrainingDataset(columnInfo);

            double value = 0;
            if (columnInfo.getDataType() == DataType.Number)
            {
               value = output.get(firstIndex);
            }
            if (columnInfo.getDataType() == DataType.Boolean)
            {
               value = output.get(firstIndex);
            }
            if (columnInfo.getDataType() == DataType.Category)
            {
               value = calcSuperiority(output.subList(firstIndex, endIndex));
            }

            if (value < currentMin)
            {
               minValues.put(columnInfo, value);
            }

            if (value > currentMax)
            {
               maxValues.put(columnInfo, value);
            }
         }
      }

      // second pass - calc confidence
      for (ColumnInfo columnInfo : outputColumns)
      {
         Double currentMin = minValues.get(columnInfo);
         Double currentMax = maxValues.get(columnInfo);

         int firstIndex = metadata.getFirstIndexInTrainingDataset(columnInfo);
         int endIndex = metadata.getEndIndexInTrainingDataset(columnInfo);

         DoubleList confidence = new ArrayDoubleList();

         for (int i = 0; i < forecast.size(); ++i)
         {
            DoubleList output = networkKorecast.get(i).getOutput();

            double value = 0;
            if (columnInfo.getDataType() == DataType.Number)
            {
               value = output.get(firstIndex);
            }
            if (columnInfo.getDataType() == DataType.Boolean)
            {
               value = output.get(firstIndex);
            }
            if (columnInfo.getDataType() == DataType.Category)
            {
               value = calcSuperiority(output.subList(firstIndex, endIndex));
            }

            confidence.add(JNMFMathUtils.reflectToInterval(value, currentMin, currentMax, 0, 1));
         }
View Full Code Here

Examples of org.apache.commons.collections.primitives.DoubleList

                 new TrainingDataset(trainingData.getInputsCount(), outputsCount);

         for (int i = 0; i < inputData.size(); ++i)
         {
            Sample sample = trainingData.get(i);
            DoubleList input = sample.getInput();

            forecastPerformer.analyze(input);

            DoubleList result = forecastPerformer.getResult();

            forecast.add(new Sample(sample.getId(), input, JNMFMathUtils.roundDoubleList4(result)));
         }

         forecastPerformer.setLearningEnabled(true);
View Full Code Here

Examples of org.apache.commons.collections.primitives.DoubleList

        return ListDoubleList.wrap(getList().subList(fromIndex,toIndex));
    }

    public boolean equals(Object obj) {
        if(obj instanceof DoubleList) {
            DoubleList that = (DoubleList)obj;
            if(this == that) {
                return true;
            } else if(this.size() != that.size()) {
                return false;           
            } else {
                DoubleIterator thisiter = iterator();
                DoubleIterator thatiter = that.iterator();
                while(thisiter.hasNext()) {
                    if(thisiter.next() != thatiter.next()) {
                        return false;
                    }
                }
View Full Code Here

Examples of org.apache.commons.collections.primitives.DoubleList

    protected DoubleList makeEmptyDoubleList() {
        return new ArrayDoubleList();
    }
   
    protected DoubleList makeFullDoubleList() {
        DoubleList list = makeEmptyDoubleList();
        double[] elts = getFullElements();
        for(int i=0;i<elts.length;i++) {
            list.add((double)elts[i]);
        }
        return list;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.