Package org.apache.commons.collections.primitives

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


      return result;
   }

   public static DoubleList asList(double... vals)
   {
      DoubleList list = new ArrayDoubleList();
      for (int i = 0; i < vals.length; ++i)
      {
         list.add(vals[i]);
      }

      return list;
   }
View Full Code Here


   {
      double min = Double.MAX_VALUE;

      for (int i = 0; i < networkResults.size(); ++i)
      {
         DoubleList output = networkResults.get(i);
         double m = output.get(JNMFMathUtils.indexOfMinElement(output));

         if (m < min)
         {
            min = m;
         }
View Full Code Here

   {
      double max = Integer.MIN_VALUE;

      for (int i = 0; i < networkResults.size(); ++i)
      {
         DoubleList output = networkResults.get(i);
         double m = output.get(JNMFMathUtils.indexOfMaxElement(output));

         if (m > max)
         {
            max = m;
         }
View Full Code Here

   {
      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

      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

      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

      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

   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

   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

      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

TOP

Related Classes of org.apache.commons.collections.primitives.DoubleList

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.