Package uk.org.ogsadai.tuple

Examples of uk.org.ogsadai.tuple.TupleMetadata


    {


     
        TupleListIterator tuples = (TupleListIterator)iterationInputs[0];
        TupleMetadata metadata = (TupleMetadata)tuples.getMetadataWrapper().getMetadata();
        Map<Integer, List<Object>> nominalValues =
            getNominalValues(iterationInputs, metadata);
        Instances dataset = WekaUtilities.createAssociationDataset(tuples, nominalValues);
        String options = TupleUtilities.getAsString(iterationInputs[1], INPUT_OPTIONS);
        String algorithmClass = TupleUtilities.getAsString(iterationInputs[2], INPUT_ALGORITHM_CLASS);
        Associator associator;
        try
        {
          associator = loadAssociator(options, algorithmClass);
          if(associator instanceof Apriori) {
            ((Apriori)associator).setTreatZeroAsMissing(true);

          }
            TupleAssociator tupleAssociator =
                new TupleAssociator(
                        associator,
                        WekaUtilities.getAttributes(dataset));
          
            associator.buildAssociations(dataset);
            mOutputAssociator.write(ControlBlock.LIST_BEGIN);
            mOutputAssociator.write(tupleAssociator.getAssociator());
            mOutputAssociator.write(ControlBlock.LIST_END);
            if(mOutputRules != null && ((AssociationRulesProducer)tupleAssociator.getAssociator()).getAssociationRules().getRules().size() > 0 ) {
              mOutputRules.write(ControlBlock.LIST_BEGIN);
             
              ArrayList<ColumnMetadata> columns = new ArrayList<ColumnMetadata>();
              columns.add(new SimpleColumnMetadata("Rule", TupleTypes._STRING,
                      0,
                      ColumnMetadata.COLUMN_NO_NULLS,
                      0));
                     
              String[] metrics = ((AssociationRulesProducer)tupleAssociator.getAssociator()).getAssociationRules().getRules().get(0).getMetricNamesForRule();       
              for(int i = 0 ; i<metrics.length; i++) {
                SimpleColumnMetadata md = new SimpleColumnMetadata(metrics[i], TupleTypes._DOUBLE,
                        0,
                        ColumnMetadata.COLUMN_NO_NULLS,
                        0);
                columns.add(md);
               
              }
             // columns.addAll(Arrays.asList(((AssociationRulesProducer)tupleAssociator.getAssociator()).getAssociationRules().getRules().get(0).getMetricNamesForRule()));
              TupleMetadata rulesMetadata = new SimpleTupleMetadata(columns);
              mOutputRules.write(new MetadataWrapper(rulesMetadata));
              for(AssociationRule rule:((AssociationRulesProducer)tupleAssociator.getAssociator()).getAssociationRules().getRules()) {
                List<Object> elements = new ArrayList<Object>();
                elements.add(rule.toString());
                for(int i=1; i<columns.size();i++) {
View Full Code Here


            List columns = new ArrayList();
            ColumnMetadata col0 = new SimpleColumnMetadata("groupID", TupleTypes._STRING, 0, 0, 0);
            columns.add(col0);
            ColumnMetadata col1 = new SimpleColumnMetadata("groupID", TupleTypes._OBJECT, 0, 0, 0);
            columns.add(col1);
            TupleMetadata metadata = new SimpleTupleMetadata(columns);
            MetadataWrapper wrapper = new MetadataWrapper(metadata);
            mOutput.write(wrapper);
            while ((tuple = Next(tuples)) != null)
            {
                mOutput.write(tuple);
View Full Code Here

        {
            engine.eval(script);
            Invocable inv = (Invocable)engine;
            TupleProject project = inv.getInterface(TupleProject.class);
            mOutput.write(ControlBlock.LIST_BEGIN);
            TupleMetadata outputMetadata =
                project.getMetadata((TupleMetadata)tuples.getMetadataWrapper().getMetadata());
            mOutput.write(outputMetadata);
            Tuple tuple;
            while ((tuple = (Tuple)tuples.nextValue()) != null)
            {
View Full Code Here

        try
        {
            List columns = new ArrayList();
            ColumnMetadata col = new SimpleColumnMetadata("groupID", TupleTypes._STRING, 0, 0, 0);
            columns.add(col);
            TupleMetadata metadata = new SimpleTupleMetadata(columns);
            MetadataWrapper wrapper = new MetadataWrapper(metadata);
           
            mOutput.write(ControlBlock.LIST_BEGIN);
            mOutput.write(wrapper);
            Open(tuples);
View Full Code Here

               ActivityUserException
    {
        int linearIndex = ((Number)iterationInputs[0]).intValue();
        TupleListIterator tuples = (TupleListIterator)iterationInputs[1];
        MetadataWrapper wrapper = tuples.getMetadataWrapper();
        TupleMetadata metadata = (TupleMetadata)wrapper.getMetadata();
        validateLinearIndex(linearIndex, metadata);
        List<UpdateableTuple> data = getTuples(tuples);
        filter(linearIndex, data);
        writeOutput(wrapper, data);
    }
View Full Code Here

        List columns = new ArrayList();
        ColumnMetadata col0 = new SimpleColumnMetadata("ID", TupleTypes._STRING, 0, 0, 0);
        columns.add(col0);
        ColumnMetadata col1 = new SimpleColumnMetadata("ITEMS", TupleTypes._STRING, 0, 0, 0);
        columns.add(col1);
        TupleMetadata metadata = new SimpleTupleMetadata(columns);
        MetadataWrapper wrapper = new MetadataWrapper(metadata);
        mOutput.write(wrapper);
        while ((tuple = Next(tuples)) != null)
        {
            mOutput.write(tuple);
View Full Code Here

                                    INPUT_METHODS,
                                    INPUT_CAUSE,
                                    INPUT_PARAMETERS }));
        }

        TupleMetadata metadata =
            (TupleMetadata) tupleList.getMetadataWrapper().getMetadata();

        // load all intervals
        mInterval = DPPHelper.loadIntervals(metadata, pmml.getPMML());
View Full Code Here

            return;
        }
        LOG.debug("Started BuildIterationalClassifier");
        Map<Integer, List<Object>> nominalValues = getNominalValues();
        TupleListIterator tuples = new FullListTupleListIterator(INPUT_DATA, mDataInput);
        TupleMetadata metadata = (TupleMetadata)tuples.getMetadataWrapper().getMetadata();
      columns = "Trained on: [";
      for(int i=0; i<metadata.getColumnCount();i++)
        columns += metadata.getColumnMetadata(i).getName() + " ";
     
      columns += "]\n";
        Instances dataset = WekaUtilities.createEmptyDataset(metadata, classIndex, nominalValues);
        if(mDescriptionInput != null)
          description = TupleUtilities.getString(readBlock(mDescriptionInput), INPUT_DESCRIPTION);
View Full Code Here

        try
        {
            List columns = new ArrayList();
            ColumnMetadata col = new SimpleColumnMetadata("row", TupleTypes._STRING, 0, 0, 0);
            columns.add(col);
            TupleMetadata metadata = new SimpleTupleMetadata(columns);
            MetadataWrapper wrapper = new MetadataWrapper(metadata);
           
            mOutput.write(ControlBlock.LIST_BEGIN);
            mOutput.write(wrapper);
            Open(tuples2);
View Full Code Here

            throws ActivityProcessingException, ActivityTerminatedException,
            ActivityUserException
    {
        String template = (String)iterationData[0];
        TupleListIterator tuples = (TupleListIterator)iterationData[1];
        TupleMetadata metadata = (TupleMetadata) tuples.getMetadataWrapper().getMetadata();
        StringReplacer replacer = new StringReplacer(template, metadata);
        Tuple tuple;
        while ((tuple = (Tuple)tuples.nextValue()) != null)
        {
            String output = replacer.createString(tuple);
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.