Package uk.org.ogsadai.tuple

Examples of uk.org.ogsadai.tuple.TupleMetadata


    // No post processing
   
  }

  private MetadataWrapper prepareMetadata(TupleListIterator tuples) throws ActivityUserException, ActivityProcessingException, ActivityTerminatedException {
        TupleMetadata prevMetadata = (TupleMetadata)tuples.getMetadataWrapper().getMetadata();
        List<ColumnMetadata> columns = new ArrayList<ColumnMetadata>();
        ColumnMetadata column = new SimpleColumnMetadata(prevMetadata.getColumnMetadata(0).getName(), TupleTypes._STRING, 0, 0, 0);
        columns.add(column);
        TupleMetadata metadata = new SimpleTupleMetadata(columns);
    return new MetadataWrapper(metadata);
  }
View Full Code Here


            ActivityUserException
    {

        List<ClassifierPriorityPair> classifiers = getClassifiers(iterationInputs);
        TupleListIterator tuples = (TupleListIterator)iterationInputs[0];
        TupleMetadata metadata =
            (TupleMetadata)tuples.getMetadataWrapper().getMetadata();
        try
        {
          boolean isNumeric = classifiers.get(0).classifier.classIsNumeric();
            mOutput.write(ControlBlock.LIST_BEGIN);
            ColumnMetadata column;
            if (isNumeric)
            {
                column = new SimpleColumnMetadata("class", TupleTypes._DOUBLE, 0, 0, 0);               
            }
            else
            {
                column = new SimpleColumnMetadata("class", TupleTypes._STRING, 0, 0, 0);
            }
           
            TupleMetadata outMetadata = new SimpleTupleMetadata(Collections.singletonList(column));
            mOutput.write(new MetadataWrapper(outMetadata));
            Tuple tuple;
            while ((tuple = (Tuple)tuples.nextValue()) != null)
            {
               
View Full Code Here

  @Override
  protected void processIteration(Object[] iterationInputs)
      throws ActivityProcessingException, ActivityTerminatedException,
      ActivityUserException {
    TupleListIterator tuples = (TupleListIterator) iterationInputs[0];
    TupleMetadata metadata = (TupleMetadata) tuples.getMetadataWrapper()
        .getMetadata();
    int classIndex = TupleUtilities.getColumnIndex(iterationInputs[1],
        metadata, INPUT_CLASS_INDEX);

    Map<Integer, List<Object>> nominalValues = getNominalValues(
View Full Code Here

            ActivityUserException
    {
        TupleClassifier classifier = (TupleClassifier)iterationData[0];
        TupleListIterator tuples = (TupleListIterator)iterationData[1];
        String resultColumnName = (String)iterationData[2];
        TupleMetadata metadata =
            (TupleMetadata)tuples.getMetadataWrapper().getMetadata();
        try
        {
            classifier.configure(metadata);
            boolean isNumeric = classifier.classIsNumeric();
            mOutput.write(ControlBlock.LIST_BEGIN);
            ColumnMetadata column;
            if (isNumeric)
            {
                column = new SimpleColumnMetadata(resultColumnName, TupleTypes._DOUBLE, 0, 0, 0);               
            }
            else
            {
                column = new SimpleColumnMetadata(resultColumnName, TupleTypes._STRING, 0, 0, 0);
            }
            TupleMetadata outMetadata = new SimpleTupleMetadata(Collections.singletonList(column));
            mOutput.write(new MetadataWrapper(outMetadata));
            Tuple tuple;
            while ((tuple = (Tuple)tuples.nextValue()) != null)
            {
                Object result;
View Full Code Here

               ActivityProcessingException,
               ActivityTerminatedException
    {
        Tuple tuple;
        // create instances metadata
        TupleMetadata metadata =
            (TupleMetadata)tuples.getMetadataWrapper().getMetadata();
        ArrayList<Attribute> attributes = getAttributes(metadata, nominalValues);
        // initial capacity of 100
        Instances instances = new Instances("", attributes, 100);
       
View Full Code Here

      ActivityTerminatedException, ActivityUserException {
    FullListTupleListIterator items = new FullListTupleListIterator(INPUT_ITEM_LIST, mItemList);
    TupleListIterator customers = new FullListTupleListIterator(INPUT_CUSTOMERS_LIST, mCustomerList);
    Integer keyIndex= getKeyIndex();
   
    TupleMetadata metadata = prepareMetadata(items);
    Set<Entry<Integer, String[]>> set = prepareList(customers, metadata, keyIndex, 1);
   
    try {
        mOutput.write(ControlBlock.LIST_BEGIN);
        mOutput.write(new MetadataWrapper(metadata));
View Full Code Here

        columns.add(new SimpleColumnMetadata(item.getString(1), TupleTypes._STRING,
                    0,
                    ColumnMetadata.COLUMN_NO_NULLS,
                    0));       
      }
      TupleMetadata metadata = new SimpleTupleMetadata(columns);
    return metadata;
    }
View Full Code Here

            iterativeStageComplete();
            return;
        }
        LOG.debug("Started BuildClassifier");
        TupleListIterator tuples = new FullListTupleListIterator(INPUT_DATA, mDataInput);
        TupleMetadata metadata = (TupleMetadata)tuples.getMetadataWrapper().getMetadata();
        int classIndex = getClassIndex(classIndexBlock, metadata);
        Map<Integer, List<Object>> nominalValues = getNominalValues(metadata);
        Instances dataset = WekaUtilities.createClassificationDataset(tuples, classIndex, nominalValues);
        String options;
        if(mOptionsInput != null)
          options = TupleUtilities.getWekaOptions(readBlock(mOptionsInput));
        else
          options = DEFAULT_OPTIONS;
       

        if(mAlgorithmClassInput != null)
          mAlgorithmClass = TupleUtilities.getString(readBlock(mAlgorithmClassInput), INPUT_ALGORITHM_CLASS);
        else
          mAlgorithmClass = mClassifierName;
       
        LOG.debug("WEKA options = " + options);
        LOG.debug("Classifier class name = " + mAlgorithmClass);

        Classifier classifier;
        try
        {
          classifier = loadClassifier(options);
            classifier.buildClassifier(dataset);
           
            if(mSummaryOutput != null)
            {
                StringBuilder columns = new StringBuilder();
              columns.append("Trained on: [");
              for(int i=0; i<metadata.getColumnCount(); i++)
              {
                columns.append(metadata.getColumnMetadata(i).getName());
                columns.append(" ");
              }
              columns.append("]\n");
                mSummaryOutput.write(ControlBlock.LIST_BEGIN);
                String description = "";
View Full Code Here

                            TupleTypes._LONG,
                            0,
                            ColumnMetadata.COLUMN_NO_NULLS,
                            0));
        }
        TupleMetadata metadata = new SimpleTupleMetadata(columns);
        try
        {
            mOutput.write(ControlBlock.LIST_BEGIN);
            mOutput.write(new MetadataWrapper(metadata));
            for (Object key : confusionMatrix.keySet())
View Full Code Here

    protected void processIteration(Object[] iterationInputs)
            throws ActivityProcessingException, ActivityTerminatedException,
            ActivityUserException
    {
        TupleListIterator tuples = (TupleListIterator)iterationInputs[0];
        TupleMetadata metadata = (TupleMetadata)tuples.getMetadataWrapper().getMetadata();
        int classIndex = TupleUtilities.getColumnIndex(iterationInputs[1], metadata, INPUT_CLASS_INDEX);
        Map<Integer, List<Object>> nominalValues =
            getNominalValues(iterationInputs, metadata);
        Instances dataset = WekaUtilities.createClassificationDataset(tuples, classIndex, nominalValues);
        String options = TupleUtilities.getAsString(iterationInputs[2], INPUT_OPTIONS);
View Full Code Here

TOP

Related Classes of uk.org.ogsadai.tuple.TupleMetadata

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.